[Help]SetWindowHookEx

Posts 1–11 of 11 · Page 1 of 1
[Help]SetWindowHookEx
im trying to make a trainer and use keyboard(numpads) to activate the HAX now i need a example of setwindowhookex. ive already looked up in google and msdn and couldnt find anything.
GetAsyncKeyState is useless in this situation.
Sorry for the late reply, I saw this earlier but I was busy.

Anyways, here's a little example.

[php]#include <windows.h>
#include <iostream>

using namespace std;


LRESULT CALLBACK KeyboardHook(int Code,WPARAM wParam, LPARAM lParam)
{
PKBDLLHOOKSTRUCT Hook = (PKBDLLHOOKSTRUCT)lParam;
if(wParam == WM_KEYDOWN)
{
if(Hook->vkCode == 'A')
{
cout<< "You pressed A";
}
}
return CallNextHookEx(0,Code,wParam,lParam);
}

int main()
{
MSG msg;
HINSTANCE hInstance = GetModuleHandle(NULL);
SetWindowsHookEx(WH_KEYBOARD_LL,KeyboardHook,hInst ance,0);
GetMessage(&msg,0,0,0);
}
[/php]

I'm pretty sure you know what to do from here.

I won't take any credit for this, B1ackAnge1 posted something on this a while ago.
yes i know the rest and also ive seen this before but i just couldnt find it.thx man.one more thing what if i want to press numpads.
I'm not too sure but I think it's something like...

[php]
if(Hook->vkCode == VK_NUMPAD0)
{
//Do stuff
}
[/php]
let me try.ya it works good thx. i did 'VK_NUMPAD1' before asking and it didnt work so ya this way works.
Actually getasync works. I can't paste the code Noe because I'm on my I pod. But it works. Just make it a function and inside call getasync for a key and the do somthing like return 1 or return 2 if it is off. and go from there
Quote Originally Posted by |-|3|_][({}PT3R12 View Post
Actually getasync works. I can't paste the code Noe because I'm on my I pod. But it works. Just make it a function and inside call getasync for a key and the do somthing like return 1 or return 2 if it is off. and go from there
I think he means it doesn't work because the method is patched or detected. Not that the function itself doesn't work.
i think he means if you use getasynckeystate always return 1 or 0; at the end .but your code works in Console only i need it for MFC.
GetAsyncKeyState should work outside consoles too, I've used it in DLL's etc ;S
Yeh mine using it

Snippet:
Code:
bool getkey()
{
	if(GetAsyncKeyState(VK_F10)&0x8000){
        return true;
    }
    return false;
}
Posts 1–11 of 11 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?