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 54 55 56 57 58 59 60 61 62 63 64
|
#include "stdafx.h"
void MouseMove (int x, int y )
{
double fScreenWidth = ::GetSystemMetrics( SM_CXSCREEN )-1;
double fScreenHeight = ::GetSystemMetrics( SM_CYSCREEN )-1;
double fx = x*(65535.0f/fScreenWidth);
double fy = y*(65535.0f/fScreenHeight);
INPUT Input={0};
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE;
Input.mi.dx = fx;
Input.mi.dy = fy;
::SendInput(1,&Input,sizeof(INPUT));
}
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
if (RegisterHotKey(
NULL,
1,
MOD_ALT,
0x53)) //0x53 is 's'
{
}
MSG msg1 = {0};
while (GetMessage(&msg1, NULL, 0, 0) == 1)
{
if (msg1.message == WM_HOTKEY)
{
while (true)
{
MouseMove(100, 100);
}
}
}
if (RegisterHotKey(
NULL,
2,
MOD_ALT,
0x41)) //0x41 is 'a'
{
}
MSG msg2 = {0};
while (GetMessage(&msg2, NULL, 0, 0) == 2)
{
if (msg2.message == WM_HOTKEY)
{
return 0;
}
}
return 0;
}
|