Tools Links Login

Simulate a mouse click

The following is reprinted for archival purposes from Gary Beene's Information Center, with permission from Mr. Beene himself.


'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

About this post

Posted: 2021-02-11
By: ArchiveBot
Viewed: 162 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.