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
![]() |
"People are murdered every day. There's genocide, war, corruption. Every day, somewhere in the world, somebody sacrifices his life to save someone else. Every day, someone, somewhere makes a conscious decision to destroy someone else. People find love, people lose it. A child watches her mother beaten to death on the steps of a church. Someone goes hungry. Somebody else betrays his best friend for a woman. If you can't find that stuff in life, then you, my friend, don't know crap about life."
Last update: Wednesday, 15th July, 2009 Copyright © 2001-2010 by Lukasz Tomicki |

