winforms - c# Register Global Hotkeys without hook library (Keyboard Hooks) -


i try configure global hotkeys in c# winform application should work , without focus. played little bit hooking librarys like: link

but these libraries not working reliable decided different way. , found 1 there 1 problem: new method posted below can catch keypress, catch keydown (wm_keydown/0x100) , keyup event... not working. ideas?

code:

public form1()         {             initializecomponent();         }              [dllimport("user32.dll")]             private static extern bool registerhotkey(intptr hwnd, int id, int fsmodifiers, int vk);              [dllimport("user32.dll")]             private static extern bool unregisterhotkey(intptr hwnd, int id);                const int mod_control = 0x0002;             const int mod_shift = 0x0004;             const int wm_hotkey = 0x0312;             const int wm_keydown = 0x0100;  private void form1_load(object sender, eventargs e)         {              // hook keys             registerhotkey(this.handle, 1, mod_control, (int)0);             registerhotkey(this.handle, 2, mod_control, (int)keys.x);          }          private void form1_formclosing(object sender, formclosingeventargs e)         {             unregisterhotkey(this.handle, 1);         }          protected override void wndproc(ref message m)         {             if (m.msg == wm_hotkey && (int)m.wparam == 1)             {                 messagebox.show("here");             }             if (m.msg == wm_keydown && (int)m.wparam == 2)                 this.opacity = 100;             base.wndproc(ref m);         } 


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -