Example #1
0
        private void InstallHookButton_Click(object sender, EventArgs e)
        {
            _lowLevelKeyboardHook = new LocalWindowsHook(HookType.WH_KEYBOARD_LL, KeyBoardHookProc);

            using (Process curProcess = Process.GetCurrentProcess())
            {
                using (ProcessModule curModule = curProcess.MainModule)
                {
                    Text = curModule.ModuleName;
                    _lowLevelKeyboardHook.Install(_lowLevelKeyboardHook.GetModuleID(curModule.ModuleName));
                }
            }

            _lowLevelKeyboardHook.Install(_currentThreadId);
        }
Example #2
0
 public FocusManagerImpl(DockPanel dockPanel)
 {
     m_dockPanel                     = dockPanel;
     m_localWindowsHook              = new LocalWindowsHook(Win32.HookType.WH_CALLWNDPROCRET);
     m_hookEventHandler              = new LocalWindowsHook.HookEventHandler(HookEventHandler);
     m_localWindowsHook.HookInvoked += m_hookEventHandler;
     m_localWindowsHook.Install();
 }
Example #3
0
            // Use a static instance of the windows hook to prevent stack overflows in the windows kernel.
            static FocusManagerImpl()
            {
                if (Win32Helper.IsRunningOnMono)
                {
                    return;
                }

                sm_localWindowsHook = new LocalWindowsHook(Win32.HookType.WH_CALLWNDPROCRET);
                sm_localWindowsHook.Install();
            }
 public FocusManagerImpl(DockPanel dockPanel)
 {
     m_dockPanel = dockPanel;
     if (!NativeMethods.ShouldUseWin32())
     {
         return;
     }
     m_localWindowsHook              = new LocalWindowsHook(Win32.HookType.WH_CALLWNDPROCRET);
     m_hookEventHandler              = new LocalWindowsHook.HookEventHandler(HookEventHandler);
     m_localWindowsHook.HookInvoked += m_hookEventHandler;
     m_localWindowsHook.Install();
 }
Example #5
0
            public FocusManagerImpl(DockPanel dockPanel)
            {
                m_dockPanel = dockPanel;
                if (Win32Helper.IsRunningOnMono)
                {
                    return;
                }
                m_hookEventHandler = new LocalWindowsHook.HookEventHandler(HookEventHandler);

                // Ensure the windows hook has been created for this thread
                if (sm_localWindowsHook == null)
                {
                    sm_localWindowsHook = new LocalWindowsHook(Win32.HookType.WH_CALLWNDPROCRET);
                    sm_localWindowsHook.Install();
                }

                sm_localWindowsHook.HookInvoked += m_hookEventHandler;
            }
			public FocusManagerImpl(DockPanel dockPanel) {
				m_dockPanel = dockPanel;
				m_localWindowsHook = new LocalWindowsHook(Win32.HookType.WH_CALLWNDPROCRET);
				m_hookEventHandler = new LocalWindowsHook.HookEventHandler(HookEventHandler);
				m_localWindowsHook.HookInvoked += m_hookEventHandler;
				m_localWindowsHook.Install();
			}
            public FocusManagerImpl(DockPanel dockPanel)
            {
                m_dockPanel = dockPanel;
                if (Win32Helper.IsRunningOnMono)
                    return;
                m_hookEventHandler = new LocalWindowsHook.HookEventHandler(HookEventHandler);

                // Ensure the windows hook has been created for this thread
                if (sm_localWindowsHook == null)
                {
                    sm_localWindowsHook = new LocalWindowsHook(Win32.HookType.WH_CALLWNDPROCRET);
                    sm_localWindowsHook.Install();
                }

                sm_localWindowsHook.HookInvoked += m_hookEventHandler;
            }
Example #8
0
 private void InstallHookButton_Click(object sender, EventArgs e)
 {
     _localMouseHook = new LocalWindowsHook(HookType.WH_MOUSE, MouseHookProc);
     _localMouseHook.Install(_currentThreadId);
 }
Example #9
0
            public FocusManagerImpl(DockPanel dockPanel)
            {
                m_dockPanel = dockPanel;

                if (Win32Helper.IsRunningOnMono())
                    return;

                m_localWindowsHook = new LocalWindowsHook(Win32.HookType.WH_CALLWNDPROCRET);
                m_hookEventHandler = new LocalWindowsHook.HookEventHandler(HookEventHandler);
                m_localWindowsHook.HookInvoked += m_hookEventHandler;
                m_localWindowsHook.Install();
            }
            // Use a static instance of the windows hook to prevent stack overflows in the windows kernel.
            static FocusManagerImpl()
            {
                if (Win32Helper.IsRunningOnMono)
                    return;

                sm_localWindowsHook = new LocalWindowsHook(Win32.HookType.WH_CALLWNDPROCRET);
                sm_localWindowsHook.Install();
            }
Example #11
0
        /// <summary>
        /// Shows the context menu
        /// </summary>
        /// <param name="handleOwner">Window that will get messages</param>
        /// <param name="arrFI">FileInfos (should all be in same directory)</param>
        /// <param name="pointScreen">Where to show the menu</param>
        public void ShowContextMenu(IntPtr handleOwner, FileInfo[] arrFI, Point pointScreen)
        {
            // Release all resources first.
            ReleaseAll();

            IntPtr           pMenu = IntPtr.Zero;
            LocalWindowsHook hook  = new LocalWindowsHook(HookType.WH_CALLWNDPROC);

            hook.HookInvoked += new LocalWindowsHook.HookEventHandler(WindowsHookInvoked);

            try
            {
                //Application.AddMessageFilter(this);

                _arrPIDLs = GetPIDLs(arrFI);
                if (null == _arrPIDLs)
                {
                    ReleaseAll();
                    return;
                }

                if (false == GetContextMenuInterfaces(_oParentFolder, _arrPIDLs))
                {
                    ReleaseAll();
                    return;
                }

                pMenu = User32.CreatePopupMenu();

                int nResult = _oContextMenu.QueryContextMenu(
                    pMenu,
                    0,
                    CMD_FIRST,
                    CMD_LAST,
                    CMF.EXPLORE |
                    CMF.NORMAL |
                    ((Control.ModifierKeys & Keys.Shift) != 0 ? CMF.EXTENDEDVERBS : 0));

                hook.Install();

                uint nSelected = User32.TrackPopupMenuEx(
                    pMenu,
                    TPM.RETURNCMD,
                    pointScreen.X,
                    pointScreen.Y,
                    handleOwner,
                    IntPtr.Zero);

                User32.DestroyMenu(pMenu);
                pMenu = IntPtr.Zero;

                if (nSelected != 0)
                {
                    InvokeCommand(_oContextMenu, nSelected, _strParentFolder, pointScreen);
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                hook.Uninstall();
                if (pMenu != IntPtr.Zero)
                {
                    User32.DestroyMenu(pMenu);
                }
                ReleaseAll();
            }
        }
 public FocusManagerImpl(DockPanel dockPanel)
 {
     m_dockPanel = dockPanel;
     if (!NativeMethods.ShouldUseWin32()) return;
     m_localWindowsHook = new LocalWindowsHook(Win32.HookType.WH_CALLWNDPROCRET);
     m_hookEventHandler = new LocalWindowsHook.HookEventHandler(HookEventHandler);
     m_localWindowsHook.HookInvoked += m_hookEventHandler;
     m_localWindowsHook.Install();
 }