后台点击代码,不报错,也没点击,求改
Public Class Form1Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'常量声明
Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const WM_MBUTTONDBLCLK = &H209
Private Const WM_MBUTTONDOWN = &H207
Private Const WM_MBUTTONUP = &H208
Private Const WM_RBUTTONDBLCLK = &H206
Private Const WM_RBUTTONDOWN = &H204
Private Const WM_RBUTTONUP = &H205
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim lpClassName As String, lpWindowName As String, hWndX As Long
lpClassName = "XLMAIN" '窗口的类名
lpWindowName = "Microsoft Excel - 111.xls" '窗口的标题
hWndX = FindWindow(lpClassName, lpWindowName) '这一步获得窗口的句柄,发送消息时需要
Dim wMsg As Long, wParam As Long, lParam As Long, Rx As Long, xx As Integer, yy As Integer
xx = 200 '点击的x坐标
yy = 300 '点击的y坐标
wMsg = WM_LBUTTONDOWN '左键按下消息
wParam = 1
lParam = yy * 65536 + xx
Call PostMessage(hWndX, wMsg, wParam, lParam) '发送消息
Sleep(300)
wMsg = WM_LBUTTONUP '左键抬起消息
wParam = 1
lParam = yy * 65536 + xx
Call PostMessage(hWndX, wMsg, wParam, lParam) '发送消息
End Sub
End Class