Beispiel #1
0
        public void InitShellEvents()
        {
            try
            {
                hookWin = new NativeWindowEx();
                hookWin.CreateHandle(new CreateParams());

                //Register to receive shell-related events
                if (User32.RegisterShellHookWindow(hookWin.Handle) == false)
                {
                    throw new System.ComponentModel.Win32Exception();
                }
                else
                {
                    //No error occurred
                    WM_SHELLHOOKMESSAGE = User32.RegisterWindowMessage("SHELLHOOK");
                    hookWin.MessageRecieved += ShellWinProc;
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
                throw ex;
            }
        }
Beispiel #2
0
 public KeyboardHook()
 {
     hotKeyWin = new NativeWindowEx();
     hotKeyWin.CreateHandle(new System.Windows.Forms.CreateParams());
     hotKeyWin.MessageRecieved += new NativeWindowEx.MessageRecievedEventHandler(hotKeyWin_MessageRecieved);
 }