Results 1 to 3 of 3

Thread: mouse buttons

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 1999
    Location
    Daly City, CA, USA
    Posts
    7

    Talking

    Hi, How can I control the mouse buttons?? like I want to "click" the left button, but i didn't actually touch the mouse. Not just get info from the button, but also be able to control them.

  2. #2
    New Member
    Join Date
    Jun 2000
    Posts
    15
    UMM...

    You could use the API mouse_event function to create a left click event.

    E.g

    Public Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
    Public Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
    Public 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)

    public sub LeftClick()
    mouse_event MOUSEEVENTF_LEFTDOWN, 0&, 0&, 0&, 0&
    mouse_event MOUSEEVENTF_LEFTUP, 0&, 0&, 0&, 0&
    end sub

    To create a click event


  3. #3
    Guest
    You can also use the SendMessage API.

    Code for a module.
    Code:
    Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Public Const WM_LBUTTONDBLCLK = &H203   ' Left Button Double Clicked
    Public Const WM_LBUTTONDOWN = &H201    ' Left Button Down   
    Public Const WM_LBUTTONUP = &H202      ' Left Button Up
    Public Const WM_RBUTTONDBLCLK = &H206  ' Right Button Double Clicked
    Public Const WM_RBUTTONDOWN = &H204    ' Right Button Down
    Public Const WM_RBUTTONUP = &H205      ' Right Button Up
    Make 2 CommandButton's on your Form and put the following code in it.

    Code:
    Private Sub Command1_Click()
    
        ' Set a Message to Command2 with the Leftbutton Down
        retval = SendMessage(Command2.hwnd, WM_LBUTTONDOWN, CLng(0), CLng(0))
    
    End Sub
    
    
    Private Sub Command2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    ' You you press Command1, it should trigger this event
    End
    
    End Sub
    Now, when you press Command1, the program will end, as if you pressed Command2.

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