1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
// Clic_ici.c
#define _WIN32_WINNT 0x0500
#include <windows.h>
#define X 700 // Coordonnees x et y du clic
#define Y 450
//---------------------------------------------------------
void CALLBACK TimerProc(HWND a, UINT b, UINT_PTR c, DWORD d)
{ // Positionne le curseur souris et simule un clic gauche
INPUT i[2];
ZeroMemory(i, sizeof(i));
i[0].type = i[1].type = INPUT_MOUSE;
i[0].mi.dx = (65535. / (double)GetSystemMetrics(SM_CXSCREEN)) * X;
i[0].mi.dy = (65535. / (double)GetSystemMetrics(SM_CYSCREEN)) * Y;
i[0].mi.dwFlags = MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_LEFTDOWN;
i[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;
SendInput(2, i, sizeof(INPUT));
MessageBeep(0);
}
//---------------------------------------------------------
int WINAPI WinMain(HINSTANCE a, HINSTANCE b, LPSTR c, int d)
{
MSG m;
UINT_PTR t;
// Une seule instance
CreateMutex(0, 0, "Clic_ici");
if(GetLastError() == ERROR_ALREADY_EXISTS)
return 1;
// Toutes les minutes ...
t = SetTimer(0, 1, 60000, TimerProc);
// Ctrl + Alt + Q pour quitter
RegisterHotKey(0, 1, MOD_CONTROL|MOD_ALT, 'Q');
while(GetMessage(&m, 0, 0, 0))
{
DispatchMessage(&m);
if(m.message == WM_HOTKEY)
if(m.wParam == 1)
break;
}
UnregisterHotKey(0, 1);
KillTimer(0, t);
return 0;
} |
Partager