Código
// Hook al Ratón #include <stdio.h> #include <stdlib.h> #include <windows.h> LRESULT CALLBACK LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam) { PMSLLHOOKSTRUCT raton = (PMSLLHOOKSTRUCT)lParam; return CallNextHookEx(NULL, nCode, wParam, lParam); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { HHOOK MouseHook = SetWindowsHookEx(WH_MOUSE_LL,LowLevelMouseProc,hInstance,0); MessageBoxA(0,"Si pulsas aceptar acabará el programa",0,0); return 0; }
Pueden dar su opinión si piensan que hay una manera mas óptima de hacerlo.
saludos.
Si quieres inutilizar el raton:
Código
LRESULT CALLBACK LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam) { PMSLLHOOKSTRUCT raton = (PMSLLHOOKSTRUCT)lParam; if (raton->pt.x != 0 || raton->pt.y != 0); { SetCursorPos(0,0); } return CallNextHookEx(NULL, nCode, wParam, lParam); }