send mouse click api - Programmers Heaven

Howdy, Stranger!

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

Categories

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.