.net - Redirecting keydown by hook in C#? -


i want write application hotkey helpers games, example, in warcraft 3, use numpad keys reason. possible send "numpad 1 key pressed" message os pressing "x" key? i've been trying using hooks couldn't figure out. hope clear.

i've used class hooks: global system hooks in .net.

simply code this:

globalkeyboardhook hook = new globalkeyboardhook(); // global hook  private void btnhook_click(object sender, eventargs e) {     hook.hook(); // set hook     hook.hookedkeys.add(keys.x); // hook x key     // removed other hooks purify code, 6 hooks total.     hook.keydown += new keyeventhandler(hook_keydown); // add eventhandler     program.hookactive = true; // inform program hook active.     guncelle(); // update form components (buttons enabling/disabling according hook status etc.) }  private void hook_keydown(object sender, keyeventargs e) {     keyeventargs k = new keyeventargs(keys.noname);     switch (e.keycode)     {         case keys.x:             k = new keyeventargs(keys.numpad1);             onkeydown(k);             break;             // removed other cases purify code, 6 cases total.     } } 

yes, can use winapi sendinput() or keyb_event() calls. example:

keybd_event(vk_numpad1, 0, 0, 0) 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -