OK:
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <iostream>
#include <fstream>
#include <stdlib.h>
HHOOK KeyboardHook;
LRESULT LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode == HC_ACTION)
{
MSLLHOOKSTRUCT *HookStruct = (MSLLHOOKSTRUCT *)lParam;
std::ofstream File("C:/koord.txt", std::ios::app);
File << HookStruct->pt.x << ", " << HookStruct->pt.y << std::endl;
}
return CallNextHookEx(KeyboardHook, nCode, wParam, lParam);
}
void InstallHook(void)
{
if(KeyboardHook)
return;
KeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC )LowLevelMouseProc, GetModuleHandle(0), 0);
if(!KeyboardHook)
{
MessageBox(0, "Failed to install Hook", "PageDown Remover", MB_OK);
}
}
void UnInstallHook(void)
{
if(KeyboardHook)
UnhookWindowsHookEx(KeyboardHook);
KeyboardHook = 0;
}
int main()
{
InstallHook();
MessageBox(0, "Hit Ok to close", "PageDown Remover", MB_OK);
UnInstallHook();
return EXIT_SUCCESS;
}
Indlæg senest redigeret d. 26.01.2008 01:14 af Bruger #11328