|
-
Nov 1st, 2000, 01:57 PM
#1
Thread Starter
New Member
How can I send mouse clicks to other applications? Please give me the exact syntax to send a LeftButtonClick, to the client area of another application
-
Nov 1st, 2000, 03:12 PM
#2
Code:
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const MK_LBUTTON = &H1
Private Sub Command1_Click()
'Send a click to a window
PostMessage HwndOfWindow, WM_LBUTTONDOWN, MK_LBUTTON, 0
PostMessage HwndOfWindow, WM_LBUTTONUP, MK_LBUTTON, 0
End Sub
-
Nov 1st, 2000, 03:15 PM
#3
If your next question is how to get the hWnd of a Window, use the FindWindowEx API.
Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const MK_LBUTTON = &H1
Private Sub Command1_Click()
Dim HwndOfWindow As Long
HwndOfWindow = FindWindowEx(0, 0, "SciCalc", "Calculator")
If HwndOfWindow <> 0 Then
'Click it
PostMessage HwndOfWindow, WM_LBUTTONDOWN, MK_LBUTTON, 0
PostMessage HwndOfWindow, WM_LBUTTONUP, MK_LBUTTON, 0
End If
End Sub
-
Dec 31st, 2007, 06:13 PM
#4
Member
Re: Sending mouse clicks to other applications
how do u specify coordinates...
-
Jan 2nd, 2008, 11:07 AM
#5
Member
Re: Sending mouse clicks to other applications
Code:
Me.Cursor.Position = New Point(x, y)
thats for moving the mouse to certain coordinates, not sure about clicking though.
i think i have a project on laptop that includes that, if i find it ill inform you.
Human beings are a disease, a cancer of this planet, you are a plague, and we are the cure.
-
Jan 3rd, 2008, 03:33 AM
#6
Hyperactive Member
Re: Sending mouse clicks to other applications
You don't need to specify coordinates when using the "FindWindow" API...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|