using namespace std;
wchar_t AdresZagolovkaOkna [500]= L"GTA:SA:MP";
HWND DeskriptorOkna;
LRESULT CALLBACK LLKeyProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode == HC_ACTION )
{
DWORD vk = ((LPKBDLLHOOKSTRUCT)lParam)->vkCode;
if(vk == 0x52 && DeskriptorOkna)
{
SendMessage(DeskriptorOkna,WM_KEYDOWN, 0x45, 0);
SendMessage(DeskriptorOkna,WM_KEYDOWN, 0x51, 0);
}
}
return CallNextHookEx(NULL, nCode, wParam, lParam);
}
int main()
{
cout << "Invalidation of the program..." << endl;
Sleep(1000);
if (!(DeskriptorOkna= FindWindow(NULL, AdresZagolovkaOkna))){
printf ("GTA:SA:MP Window not detected!\n" );
getchar ();
}
else {
printf ("GTA:SA:MP Window detected! | Descriptor: %x\n", DeskriptorOkna);
}
HHOOK hook = SetWindowsHookEx(WH_KEYBOARD_LL, LLKeyProc, GetModuleHandle(NULL), 0);
if(hook)
{
while(WaitMessage())
{
MSG msg = {0};
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
{
UnhookWindowsHookEx(hook);
return 0;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
return 0;
}