Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant archive_postsperpage - assumed 'archive_postsperpage' (this will throw an Error in a future version of PHP) in ..../archive/index.php on line 456
Keyboard hook! Help! [Archive] - Forums

PDA

View Full Version : Keyboard hook! Help!



Bruno
08-26-2007, 09:06 PM
Hello, i saw a tutorial at the tutorial section (http://www.xcreations.net/~tpforums/forum/showthread.php?t=639) Ty Kekke!
I made it, but i dont know hot to change the key I pressed, like when i press 'm' i change to 'a'!

I tried this at the hook dll:



extern "C" __declspec (dllexport) LRESULT __stdcall KeyboardProc
(int code, WPARAM wParam, LPARAM lParam)
{

if(code == HC_ACTION) //if the wparam/lparam contains any data
{
if(wParam == VK_RETURN) //if wparam (which is a vk) is return
{
return 1; //return 1, which means that the key event wont be processed
}
}

return CallNextHookEx(0, code, 65, lParam); // 65 is an 'a'
}


I can read and log the keys on a file, i press 'a' and the wParam = 65, i change it on the return, but its not working! What i need to do?

Ty!

Kekke
08-27-2007, 08:48 PM
You need a WH_CBT hook to do that.



Global WH_CBT hooks

A system-wide hook is a function that is installed in all of the running processes to monitor messages before they reach the target window procedure. Hook procedures are used to monitor the system for various types of events such as keystrokes. You can install a hook procedure by calling the SetWindowsHookEx WinAPI and specifying the type of hook calling the procedure. A WH_CBT hook procedure is called before windows get focus and before keyboard events are removed from the system message queue. A global hook procedure is called in the context of all applications in the desktop, so the procedure must reside in a separate DLL from the application installing the hook procedure.

Bruno
08-27-2007, 08:59 PM
Ty, I will try to make it, if I cant figure out something I back here and post ^^'

Cya