Mouse Clicker -
Simulating mouse clicks in windows
Windows is an event driven programming operating system. Messages are sent by applications and the Windows OS itself. Then Windows decides whether a message should be sent to a specific application. In the case of mouse clicks, mouse click events are created. When the system receives such a message it checks (base on the click's screen coordinates) which window should receive the message (this also called a hit test) and then places appropriate mouseup/mousedown/mousedbl messages in the application's message queue.
Our goal is to simulate mouse clicks just as they would happen if one simply clicked the mouse with the cursor at its current position. Our approach will be to place messages into the global Windows message queue. To achieve this, we will use the mouse_event() function. Refer to the example:
POINT p; GetCursorPos(&p); mouse_event(MOUSEEVENTF_LEFTDOWN, p.x, p.y, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, p.x, p.y, 0, 0); if (dblclick) { mouse_event(MOUSEEVENTF_LEFTDOWN, p.x, p.y, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, p.x, p.y, 0, 0); }
For more detail on the mouse_event() refer to MSDN. Simulating other actions in Windows can be done in the same manner. MSDN is your friend.
- download current stable version clicker-0.1.tar.bz2
md5sum: 233694e1275134a88bc09fc8a947ef0d clicker-0.1.tar.bz2
"Most people would rather die than think; many do." - Bertrand Russell
Last update: Thursday, 19th September, 2024 Copyright © 2001-2025 by Lukasz Tomicki |