public static void CreateHook(KeyHandler keyHandler) { var currentProcess = Process.GetCurrentProcess(); var module = currentProcess.MainModule; _hookFunction = HookFunction; _keyHandler = keyHandler; _hook = SetWindowsHookEx(LowLevelKeyboardHook, _hookFunction, GetModuleHandle(module.ModuleName), 0); }
public static void CreateHook(KeyHandler _kh) { Process _this = Process.GetCurrentProcess(); ProcessModule mod = _this.MainModule; hd = HookFunc; kh = _kh; hhk = API.SetWindowsHookEx(13, hd, API.GetModuleHandle(mod.ModuleName), 0); }
public static void CreateHook(KeyHandler _kh) { System.Diagnostics.Process _this = System.Diagnostics.Process.GetCurrentProcess(); System.Diagnostics.ProcessModule mod = _this.MainModule; hd = HookFunc; kh = _kh; hhk = API.SetWindowsHookEx(13, hd, API.GetModuleHandle(mod.ModuleName), 0); //13 is the parameter specifying that we're gonna do a low-level keyboard hook //MessageBox.Show(Marshal.GetLastWin32Error().ToString()); //for debugging //Note that this could be a Console.WriteLine(), as well. I just happened //to be debugging this in a Windows Application //to get the errors, in VS 2005+ (possibly before) do Tools -> Error Lookup }
//Creation of the hook public static void CreateHook(KeyHandler _kh) { Process _this = Process.GetCurrentProcess(); ProcessModule mod = _this.MainModule; hd = HookFunc; kh = _kh; //13 is the parameter specifying that we're gonna do a low-level keyboard hook hhk = API.SetWindowsHookEx(13, hd, API.GetModuleHandle(mod.ModuleName), 0); //MessageBox.Show(Marshal.GetLastWin32Error().ToString()); //for debugging //Note that this could be a Console.WriteLine(), as well. I just happened //to be debugging this in a Windows Application }
public static extern IntPtr SetWindowsHookEx( int idHook, HookDel lpfn, IntPtr hMod, uint dwThreadId);
public static void CreateHook(KeyHandler _kh) { Process _this = Process.GetCurrentProcess(); ProcessModule mod = _this.MainModule; hd = HookFunc; kh = _kh; hhk = API.SetWindowsHookEx(13, hd, API.GetModuleHandle(mod.ModuleName), 0); //13 is the parameter specifying that we're gonna do a low-level keyboard hook //MessageBox.Show(Marshal.GetLastWin32Error().ToString()); //for debugging //Note that this could be a Console.WriteLine(), as well. I just happened //to be debugging this in a Windows Application //to get the errors, in VS 2005+ (possibly before) do Tools -> Error Lookup }