Results 1 to 5 of 5

Thread: GetAsyncKeyState

Hybrid View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    18
    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

  2. #2
    Guest
    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    18
    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

  4. #4
    New Member
    Join Date
    Oct 2000
    Posts
    1
    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


  5. #5

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    18
    still doesnt work ( makes it worse =( )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width