|
-
Aug 7th, 1999, 10:02 PM
#1
Thread Starter
Guru
There were like 2 or 3 or a billion posts with the same question: How do you simulate a mouse click?
The answer was the same: Find the control's hWnd, and SendMessage with wMsg as WM_CLICK or 2 SendMessage's with wMsg as WM_LBUTTONDOWN then WM_LBUTTONUP.
New question arose: How do you simulate a mouse click, but not clicking the hWnd, but clicking an area of the screen (Click X, Y)?
------------------
- Yonatan
-
Aug 8th, 1999, 06:41 PM
#2
You may not like this because it includes another hWnd. Use the hWnd of the screen (desktop). I think it's zero, but I'm not sure.
-
Aug 8th, 1999, 07:01 PM
#3
Thread Starter
Guru
Zero is the hWnd of NOTHING. To get the screen hWnd you have to use the API GetDesktopWindow. Well, what do I DO with the screen's hWnd?
------------------
- Yonatan
-
Aug 17th, 1999, 06:12 PM
#4
In C/C++, you'd use
HWND GetDesktopWindow(VOID)
to return the handle for the desktop. I haven't found it in VB, but this might help you. Maybe you can find an API for it. I've noticed that you use the API's alot.
-
Aug 18th, 1999, 11:54 AM
#5
Thread Starter
Guru
No, I didn't ask how to get the screen's hWnd. I know how. I've done it a billion times.
My question was what do I do with the hWnd? To simulate a mouse click I mean?
Should I use an AOL such as SendMessageByPoint(hWnd (= GetDesktopWindow) As Long, wMsg (= WM_CLICK) As Long, lParam (= 0&) As Long, wParam As POINTAPI) ?!?!?
Well, it's worth a try!
------------------
Yonatan
Teenage Programmer
-
Dec 12th, 1999, 07:44 AM
#6
You sure were rude when I was just trying to help you out. Now you're giving similar advice:
Yonatan
Member posted 12-08-1999 05:55 PM
--------------------------------------------------------------------------------
GetDC allocates a Device-Context for the hWnd specified. This hWnd can be either:
0 (Zero) - Currently active desktop.
128 - First desktop (the one created when Windows started).
Any other number - A valid window handle.
------------------
Yonatan
Teenage Programmer
E-Mail: [email protected]
ICQ: 19552879
AIM: RYoni69
-
Dec 12th, 1999, 07:23 PM
#7
Try this:
Code:
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Type POINTAPI
X As Long
Y As Long
End Type
Public Sub ClickMouse(X As Long, Y As Long)
SetCursorPos X, Y
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
Passing your coordinates will click the left button on the mouse.
Example: ClickMouse 500, 500
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
-
Dec 13th, 1999, 12:56 PM
#8
Ask Aaron Young. He's been able to help me
with basically every VB question.
-
Dec 14th, 1999, 01:01 AM
#9
Thread Starter
Guru
This post is old and I posted it back when I was (so to speak) an idiot... Sorry!
------------------
Yonatan
Teenage Programmer
E-Mail: [email protected]
ICQ: 19552879
AIM: RYoni69
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
|