Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SetActiveWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Const BM_CLICK As Long = &HF5Private Sub Command1_Click()
Dim hwnd As Long
hwnd = FindWindow(vbNullString, "任务姿滚栏和「开始」菜单属性") '我找的是任务栏属性窗口,这里换成你要找的窗口标题
'MsgBox hwnd
Dim btnhWnd As Long
btnhWnd = FindWindowEx(hwnd, 0, "Button", "取消") '取虚册春差耐消是按按钮的标题,你要换成自己的内容
MsgBox btnhWnd
SetActiveWindow hwndSendMessage btnhWnd, BM_CLICK, 0, 0End Sub
如果你的那个图标 和 菜单的位置是固定不变的话,可以用则轿 API函数
Public Declare Function SetCursorPos Lib "user32" (ByVal x As long, ByVal y As long) As long‘这个函数可以讲鼠标移动到任意(X,Y)位置
Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As long, ByVal dx As long, ByVal dy As long, ByVal cButtons As long, ByVal dwExtraInfo As long)’模拟鼠标单击
先找到你那个图标和菜单的位悔盯乎置X 和Y,然后
dim Ret as long
Ret=SetCursorPos(X,Y)'移动到那个位置
mouse_event(&H2, 0, 0, 0, 0)'碧悉鼠标左键按下
mouse_event(&H4, 0, 0, 0, 0)‘鼠标左键d起
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)