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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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
        }
Exemplo n.º 4
0
        //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
        }
Exemplo n.º 5
0
 public static extern IntPtr SetWindowsHookEx(
     int idHook,
     HookDel lpfn,
     IntPtr hMod,
     uint dwThreadId);
Exemplo n.º 6
0
 public static extern IntPtr SetWindowsHookEx(
     int idHook,
     HookDel lpfn,
     IntPtr hMod,
     uint dwThreadId);
Exemplo n.º 7
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);
            //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
        }