Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

send mouse click api

superjoe30superjoe30 Posts: 174Member
Is there a windows api that I can call that sends a mouse click to the screen, from whereever the mouse pointer is?


_____ __________ _____
_____-[red]SUPERJOE30[/red]-_____

Comments

  • Archer282Archer282 Posts: 243Member
    : Is there a windows api that I can call that sends a mouse click to the screen, from whereever the mouse pointer is?
    :
    :
    : _____ __________ _____
    : _____-[red]SUPERJOE30[/red]-_____
    :
    :


    why yes there is

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/MouseInput/MouseInputReference/MouseInputFunctions/mouse_event.asp

    [code]
    Public Type POINTAPI
    x As Long
    y As Long
    End Type

    Public Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
    Public Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

    Public Const MOUSEEVENTF_ABSOLUTE = &H8000 ' absolute move
    Public Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
    Public Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
    Public Const MOUSEEVENTF_MIDDLEDOWN = &H20 ' middle button down
    Public Const MOUSEEVENTF_MIDDLEUP = &H40 ' middle button up
    Public Const MOUSEEVENTF_MOVE = &H1 ' mouse move
    Public Const MOUSEEVENTF_RIGHTDOWN = &H8 ' right button down
    Public Const MOUSEEVENTF_RIGHTUP = &H10 ' right button up
    [/code]

    just put that in a module or something

    example of simulating a left click

    [code]
    Dim MousePos As POINTAPI
    Call GetCursorPos(MousePos)
    mouse_event( MOUSEEVENTF_LEFTDOWN, MousePos.X, MousePos.Y, 0, 0 )
    [/code]
Sign In or Register to comment.