Global KeyboardHooks and WiondowsKeyboardHooks
-
Hi everyone, I have made a c# application (from the article: Global System Hooks in .NET By Michael Kennedy link) that installs a systemwide keyboard hook. This application emulate mouse clicks when specified key pressed. It's work fine, only a little problem with it: When keypess occures, my app hooks it, and Windows hoo too. How can I told windows not to do that? Example: I set the 0 key to do left mouse click, when I press 0 in a textbox or in TotalCommander the click occures, and a 0 character appears in the textbox too :sigh: Hope somebody can help me :-> PS: Sorry about my english
-
Hi everyone, I have made a c# application (from the article: Global System Hooks in .NET By Michael Kennedy link) that installs a systemwide keyboard hook. This application emulate mouse clicks when specified key pressed. It's work fine, only a little problem with it: When keypess occures, my app hooks it, and Windows hoo too. How can I told windows not to do that? Example: I set the 0 key to do left mouse click, when I press 0 in a textbox or in TotalCommander the click occures, and a 0 character appears in the textbox too :sigh: Hope somebody can help me :-> PS: Sorry about my english
Hi, I think you can download the Full Source of that article and make some changes on it. and recompile it. In SystemHookCore.cpp at InternalKeyboardHookCallback function you should mark last line and add
return 1;
instead of that line:static LRESULT CALLBACK InternalKeyboardHookCallback(int code, WPARAM wparam, LPARAM lparam) { if (code < 0) { return CallNextHookEx(hookKeyboard, code, wparam, lparam); } if (UserKeyboardHookCallback != NULL && !keyboardFilter.IsFiltered((int)wparam)) { UserKeyboardHookCallback(code, wparam, lparam); } return 1; // return CallNextHookEx(hookKeyboard, code, wparam, lparam); }
But I think it is a rapid solution. in addition you should add some mechanism in other class to check in application level that you want to take this action on this character or not. Ahmadreza Atighechi -
Hi, I think you can download the Full Source of that article and make some changes on it. and recompile it. In SystemHookCore.cpp at InternalKeyboardHookCallback function you should mark last line and add
return 1;
instead of that line:static LRESULT CALLBACK InternalKeyboardHookCallback(int code, WPARAM wparam, LPARAM lparam) { if (code < 0) { return CallNextHookEx(hookKeyboard, code, wparam, lparam); } if (UserKeyboardHookCallback != NULL && !keyboardFilter.IsFiltered((int)wparam)) { UserKeyboardHookCallback(code, wparam, lparam); } return 1; // return CallNextHookEx(hookKeyboard, code, wparam, lparam); }
But I think it is a rapid solution. in addition you should add some mechanism in other class to check in application level that you want to take this action on this character or not. Ahmadreza AtighechiThank's a lot! It's works fine ;) Can you tell me, how can I modify the ManagedHook or HookCore project to tell them witch cases makes this return 1 trick, and witch not. So how can I tell to the class from my C# app to do the return 1 action when my defined keys pressed, and otherwise do the normal action? I think i shoud add somethink like this: List l; Than I add my specila keys to the list, and every time keypress occures I search the list for the actual key, when I find it, do the return 1... Sorry for my stupid questions, but i not familiar with dll manipulation :sigh: I trí to modify SystemHookCore.cpp, and add a method, and a global witch set/store the keycodes, witch is exclude from system hooks. also modify the, managedhooks class, rebuild all, but when I start my app get error: "Entry point(my new function name) was nt found on systemhook.dll" :sigh: Thank's for help! -- modified at 10:29 Sunday 21st May, 2006