VB postmessage单击按钮,按钮外貌出现被点击过的虚线框,按钮里面代码没有执行
PrivateDeclareSubSleepLib"kernel32"(ByValdwMillisecondsAsLong)PrivateDeclareFunctionF...
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Dim hwd As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const MK_LBUTTON = &H1
Private Sub Command1_Click()
Dim xy As Long
hwd = FindWindow(vbNullString, "form1")
Label1.Caption = hwd
End Sub
Private Sub Command2_Click()
MsgBox "click"
End Sub
Private Sub Timer1_Timer()
xy = 20 * &H10000 + 20 '坐标400,300
PostMessage Form1.Command2.hwnd, WM_LBUTTONDOWN, 1, 0
Sleep 50
PostMessage Form1.Command2.hwnd, WM_LBUTTONUP, 1, 0
End Sub
以上是代码,求解决方案 展开
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Dim hwd As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const MK_LBUTTON = &H1
Private Sub Command1_Click()
Dim xy As Long
hwd = FindWindow(vbNullString, "form1")
Label1.Caption = hwd
End Sub
Private Sub Command2_Click()
MsgBox "click"
End Sub
Private Sub Timer1_Timer()
xy = 20 * &H10000 + 20 '坐标400,300
PostMessage Form1.Command2.hwnd, WM_LBUTTONDOWN, 1, 0
Sleep 50
PostMessage Form1.Command2.hwnd, WM_LBUTTONUP, 1, 0
End Sub
以上是代码,求解决方案 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询