Im using C# trying to catch keyboard input, the codes are like below. Now whats bothering me is that the callback function will be triggered correctly but each time itll take much time to respond and during this period I can not do noting but wait coz
the whole system has been blocked. HALP~~
//Add a hook
private void KeyboardHookStart()<br/>
{<br/>
KeyboardHookProcedure = new HookProc(KeyboardHookProc);<br/>
hKeyboardHook = SetWindowsHookEx(13, KeyboardHookProcedure,<br/>
Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]), 0);
if (hKeyboardHook == 0)<br/>
{<br/>
KeyboardHookStop();<br/>
throw new Exception("Failed to Add New Keyboard Hook!");<br/>
}<br/>
}
//Callback function
private int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam)<br/>
{<br/>
if (wParam != 0x100)<br/>
return 0;<br/>
MessageBox.Show("woolaa");<br/>
return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam);<br/>
}
View the full article
the whole system has been blocked. HALP~~
//Add a hook
private void KeyboardHookStart()<br/>
{<br/>
KeyboardHookProcedure = new HookProc(KeyboardHookProc);<br/>
hKeyboardHook = SetWindowsHookEx(13, KeyboardHookProcedure,<br/>
Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]), 0);
if (hKeyboardHook == 0)<br/>
{<br/>
KeyboardHookStop();<br/>
throw new Exception("Failed to Add New Keyboard Hook!");<br/>
}<br/>
}
//Callback function
private int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam)<br/>
{<br/>
if (wParam != 0x100)<br/>
return 0;<br/>
MessageBox.Show("woolaa");<br/>
return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam);<br/>
}
View the full article