|
-
Apr 11th, 2001, 03:42 PM
#1
Thread Starter
Junior Member
how do i send/post a click inside another program?
if it's minmized? i know it's handle and the pos i want to click in the program
how should i do?
thanks for answering questions like these over and over again 
thanks in advance, and as always help is appreciated.
-
Apr 11th, 2001, 04:02 PM
#2
Addicted Member
Code:
Declare Function SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal
wMsg As Long, ByVal wParam As Long, lParam As Any)
Const VK_SPACE = &H20
Const WM_KEYUP = &H101
Const WM_KEYDOWN = &H100
Sub Click_Button(Handle As Long)
Call SendMessage(Handle&, WM_KEYDOWN, VK_SPACE, vbNullString)
Call SendMessage(Handle&, WM_KEYUP, VK_SPACE, vbNullString)
End Sub
Just call that sub and it'll click the button. I'm pretty sure it'll work if it's minimized
-
Apr 11th, 2001, 05:51 PM
#3
No, that wont work, since SendMessage will always wait for a return value rather than return immediately. In this case, you need to use PostMessage instead.
-
Apr 12th, 2001, 01:06 PM
#4
Thread Starter
Junior Member
but how does it know where to click?
but how does it know where to click?
dont i need to declare the coords for the click inside the prog.?
-
Apr 12th, 2001, 02:24 PM
#5
The LoWord of lParam specfies the X-coordinates, and the HiWord of lParam specfies the Y-coordinates.
-
Apr 12th, 2001, 02:39 PM
#6
Thread Starter
Junior Member
ooh :)
k
-
Apr 12th, 2001, 02:47 PM
#7
Since VB, doesn't come with any sort of MakeDWORD function, here it is:
Code:
Public Function MakeWord(ByVal LoWord As Integer, ByVal HiWord As Integer) As Long
MakeWord = (HiWord * &H10000) Or (LoWord And &HFFFF&)
End Function
Usage
Code:
Dword = MakeWord ( LoWord, HiWord )
-
Apr 12th, 2001, 02:55 PM
#8
Thread Starter
Junior Member
thx
thx for clearing that.. (for like 1 min ago i searched www.freevbcode.com) trying to find something like that but i wasn't sure what i was looking for, so thx for clearing it up!
-
Apr 13th, 2001, 10:03 AM
#9
Thread Starter
Junior Member
can't get it to work
i tried:
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
Dword = MakeWord (54, 456)
PostMessage hWndOfwindow, WM_LBUTTONDOWN, MK_LBUTTON, Dword
PostMessage hWndOfwindow, WM_LBUTTONUP, MK_LBUTTON, Dword
End Sub
****
i couldn't get that to work, it just doesn't click, recenlty i found:
Public Function IntegersToLong(LoWord As Integer, _
HiWord As Integer) As Long
IntegersToLong = (HiWord * &H10000) + (LoWord And &HFFFF&)
End Function
but i haven't tested it, maybe that's the solution?
-
Apr 13th, 2001, 05:35 PM
#10
Yes, that is the correct method (mine used Or instead of "+" ).
-
Apr 15th, 2001, 10:36 AM
#11
Actually, Or and + are the same so this should work
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
Public Function MakeWord(ByVal LoWord As Integer, ByVal HiWord As Integer) As Long
MakeWord = (HiWord * &H10000) + (LoWord And &HFFFF&)
End Function
Private Sub Command1_Click()
dword = MakeWord(4, 4)
PostMessage hwnd, WM_LBUTTONDOWN, 1, dword
PostMessage hwnd, WM_LBUTTONUP, 1, dword
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Print X / Screen.TwipsPerPixelX & "-" & Y / Screen.TwipsPerPixelY
End Sub
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
|