Results 1 to 7 of 7

Thread: How to cause the mouse to send a left-click ?

  1. #1

    Thread Starter
    Registered User Lior's Avatar
    Join Date
    Jan 2000
    Posts
    307

    Question

    Hi,
    I wanna know please how to cause the mouse to simulate a left click?
    I already know how to set the cursor to a specific position using the API, but I dont know how to send then a left click.

    Thanks.

  2. #2
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326
    Here is the method I use.



    'declarations
    Public Declare Sub mouse_event Lib "user32.dll" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy _
    As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)


    Const MOUSEEVENTF_ABSOLUTE = &H8000
    Const MOUSEEVENTF_LEFTDOWN = &H2
    Const MOUSEEVENTF_LEFTUP = &H4
    Const MOUSEEVENTF_MIDDLEDOWN = &H20
    Const MOUSEEVENTF_MIDDLEUP = &H40
    Const MOUSEEVENTF_MOVE = &H1
    Const MOUSEEVENTF_RIGHTDOWN = &H8
    Const MOUSEEVENTF_RIGHTUP = &H10
    Const MOUSEEVENTF_WHEEL = &H80
    Const MOUSEEVENTF_XDOWN = &H100
    Const MOUSEEVENTF_XUP = &H200
    Const WHEEL_DELTA = 120
    Const XBUTTON1 = &H1
    Const XBUTTON2 = &H2


    'to hold the left button down
    mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
    'and then release the button
    mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0

    You can use the constants above to simulate other mouse activity.

  3. #3
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326
    I can't edit my last post so...

    <code>
    'declarations
    Public Declare Sub mouse_event Lib "user32.dll" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy _
    As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)


    Const MOUSEEVENTF_ABSOLUTE = &H8000
    Const MOUSEEVENTF_LEFTDOWN = &H2
    Const MOUSEEVENTF_LEFTUP = &H4
    Const MOUSEEVENTF_MIDDLEDOWN = &H20
    Const MOUSEEVENTF_MIDDLEUP = &H40
    Const MOUSEEVENTF_MOVE = &H1
    Const MOUSEEVENTF_RIGHTDOWN = &H8
    Const MOUSEEVENTF_RIGHTUP = &H10
    Const MOUSEEVENTF_WHEEL = &H80
    Const MOUSEEVENTF_XDOWN = & H100
    Const MOUSEEVENTF_XUP = &H200
    Const WHEEL_DELTA = 120
    Const XBUTTON1 = &H1
    Const XBUTTON2 = &H2


    'to hold the left button down
    mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
    'and then release the button
    mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0

    </code>
    You can use the constants above to simulate other mouse activity.

  4. #4
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326
    ok... fine forget it

  5. #5
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Hehe Square brackets Chris - [like these]
    Harry.

    "From one thing, know ten thousand things."

  6. #6

    Thread Starter
    Registered User Lior's Avatar
    Join Date
    Jan 2000
    Posts
    307

    not working.

    Hi
    thanks for trying to help, BUT it is still not working.
    it cant use the &H2 value as the first parameter in the procedure.
    any other ideas guys?
    thanks.

  7. #7

    Thread Starter
    Registered User Lior's Avatar
    Join Date
    Jan 2000
    Posts
    307

    oops...working!

    Hi
    forget what I said.
    it is now working.
    I just had to switch it from Public to Private.

    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