Results 1 to 4 of 4

Thread: left/ right click

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Hong Kong
    Posts
    4

    Post

    How can I detect the left/right if the object haven't mousedown, mousemove, mouseup... event??
    How can I make the mouse right click whereever it is on the screen through code?

  2. #2
    Addicted Member Smie's Avatar
    Join Date
    Jun 1999
    Location
    Columbus, OH
    Posts
    249

    Post

    Im not sure if this is right, for i have not tested it myself, but done something similar at one point. You will need a timer

    Sub Function Timer1_Timer()
    If Button = 1 Then
    'Place action here for the first mouse button....
    End If

    If Button = 2 Then
    'Place action here for the second mouse button
    End If
    End Sub


    Again....I havent tested it, it might have to be under a click/mouse event subform but again im not sure....

  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    To get the Status of the Left/Right Mouse Buttons wether or not a Control has any Mouse Events, you can use the GetAsyncKeyState API in a Timer, ie.
    Code:
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    
    Private Const VK_LBUTTON = &H1
    Private Const VK_RBUTTON = &H2
    Private Sub Form_Load()
        Timer1.Interval = 100
    End Sub
    
    Private Sub Timer1_Timer()
        If GetAsyncKeyState(VK_LBUTTON) Then
            Caption = "Left Click"
        ElseIf GetAsyncKeyState(VK_RBUTTON) Then
            Caption = "Right Click"
        Else
            Caption = ""
        End If
    End Sub
    To Click the Left/Right Mouse Button anywhere the Mouse Cursor Happens to be use the Mouse_Event API, ie.
    Code:
    Private 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)
    
    Private Const MOUSEEVENTF_LEFTDOWN = &H2 '  left button down
    Private Const MOUSEEVENTF_LEFTUP = &H4 '  left button up
    Private Const MOUSEEVENTF_RIGHTDOWN = &H8 '  right button down
    Private Const MOUSEEVENTF_RIGHTUP = &H10 '  right button up
    
    Private Sub DoLeftClick()
        Call mouse_event(MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0&, 0&, 0&, 0&)
    End Sub
    
    Private Sub DoRightClick()
        Call mouse_event(MOUSEEVENTF_RIGHTDOWN Or MOUSEEVENTF_RIGHTUP, 0&, 0&, 0&, 0&)
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Hong Kong
    Posts
    4

    Post

    Thanks

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