Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

Simulate a mouse click


'click mouse at specific XY (In pixels) on a form

Public 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 Sub SendClick(lnghWND As Long , x As Long , y As Long )
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202


Dim iResult As Long
Dim lParam As Long
lParam = (y * &H10000) + x
iResult = SendMessage(lnghWND, WM_LBUTTONDOWN, 0&, ByVal lnglParam)
iResult = SendMessage(lnghWND, WM_LBUTTONUP, 0&, ByVal lnglParam)
End Sub