Skip to content

Instantly share code, notes, and snippets.

@Siim
Created September 21, 2010 12:09
Show Gist options
  • Save Siim/589580 to your computer and use it in GitHub Desktop.
Save Siim/589580 to your computer and use it in GitHub Desktop.
#include <windows.h>
#include <stdio.h>
void coolSleep(int count)
{
int i;
for(i=count; i>=0; i--){
printf(".",i);
Sleep(1000);
}
}
int main(int argc, char **argv)
{
if(argc==3){
int sleep = atoi(argv[1]);
int clicks = atoi(argv[2]);
if(!(sleep>=0 && clicks>=0)){
printf("Both sleep time and click_count must be positive integers\n");
exit(EXIT_FAILURE);
}
printf("Warning!!! Starting to click in %d seconds",sleep);
coolSleep(sleep);
POINT pos;
if(GetCursorPos(&pos)){
int i;
for(i=0; i<clicks; i++){
mouse_event(MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_LEFTUP,pos.x,pos.y,0,0);
}
}else{
printf("Cannot get cursor position.\n");
exit(EXIT_FAILURE);
}
}else{
printf("Usage:\t%s time click_count\n",argv[0]);
printf("\tWhere time is sleep time before clicking event");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment