-
I`m using this code to wait for a click from the user to pause and continue the program. On some PC's it doesnt work, any idea why ? also how do i detect if its clicked on a particular form ?
Public Sub Wait4Click()
Dim press As Boolean
press = False
Do
DoEvents
If GetAsyncKeyState(1) <> 0 Then press = True
If press = True And (1) = 0 Then Exit Sub
DoEvents
Loop
End Sub
-
Give it a try...
Code:
Private Sub Wait4Click()
Dim press As Boolean
press = False
Do
If GetAsyncKeyState(vbKeyLButton) Then Debug.Print "LeftClick": press = True
If press = True And (1) = 0 Then Exit Sub
DoEvents
Loop
End Sub
-
Woops one of lines have changed but it still doesnt work on other PCs. Do i have to clear the mouse click buffer or something ?
Public Sub Wait4Click()
Dim press As Boolean
press = False
Do
If GetAsyncKeyState(vbKeyLButton) <> 0 Then press = True
If press = True And GetAsyncKeyState(vbKeyLButton) = 0 Then Exit Sub
DoEvents
Loop
End Sub
-
You can try these constant "VK_LBUTTON" in replacement of "vbKeyLButton".
Public Const VK_LBUTTON = &H1
Public Const VK_RBUTTON = &H2
Public Sub Wait4Click()
Dim press As Boolean
press = False
Do
If GetAsyncKeyState(VK_LBUTTON ) <> 0 Then press = True
If press = True And GetAsyncKeyState(VK_LBUTTON ) = 0 Then Exit Sub
DoEvents
Loop
End Sub
-
still doesnt work ( makes it worse =( )