PDA

Click to See Complete Forum and Search --> : Mouse click sequel: Rodent's Revenge


Yonatan
Aug 7th, 1999, 10:02 PM
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
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.

Yonatan
Aug 8th, 1999, 07:01 PM
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
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.

Yonatan
Aug 18th, 1999, 11:54 AM
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, 06:44 AM
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: RZvika@netvision.net.il
ICQ: 19552879
AIM: RYoni69

Serge
Dec 12th, 1999, 06:23 PM
Try this:

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
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)

Dec 13th, 1999, 11:56 AM
Ask Aaron Young. He's been able to help me
with basically every VB question.

Yonatan
Dec 14th, 1999, 12:01 AM
This post is old and I posted it back when I was (so to speak) an idiot... Sorry!

------------------
Yonatan
Teenage Programmer
E-Mail: RZvika@netvision.net.il
ICQ: 19552879 (http://www.icq.com/19552879)
AIM: RYoni69