Esempio n. 1
0
 private void StartHook()
 {
     // Mouse hook
     WindowsAPI.HookProc mouseHookProc = new WindowsAPI.HookProc(MouseHook);
     m_mouseProcHandle = GCHandle.Alloc(mouseHookProc);
     m_mouseHookHandle = WindowsAPI.SetWindowsHookEx((int)WindowsHookCodes.WH_MOUSE,
                                                     mouseHookProc, IntPtr.Zero, WindowsAPI.GetCurrentThreadId());
 }
Esempio n. 2
0
        public CallWndProcHook(WindowsAPI.WindowProc wndProc)
        {
            this.m_wndProc = wndProc;
            this.m_hookProc = new WindowsAPI.HookProc(this.CallWndProc);

            if (m_wndProc != null)
            {
                m_hHook = WindowsAPI.SetWindowsHookEx(4, m_hookProc, IntPtr.Zero, WindowsAPI.GetCurrentThreadId());
            }
        }
Esempio n. 3
0
 void StartHook()
 {
     // Mouse hook
     WindowsAPI.HookProc mouseHookProc = new WindowsAPI.HookProc(MouseHook);
     mouseProcHandle = GCHandle.Alloc(mouseHookProc);
     mouseHookHandle = WindowsAPI.SetWindowsHookEx((int)WindowsHookCodes.WH_MOUSE,
                                                   mouseHookProc, IntPtr.Zero, WindowsAPI.GetCurrentThreadId());
     if (mouseHookHandle == IntPtr.Zero)
     {
         throw new SecurityException();
     }
 }
Esempio n. 4
0
		void TrackDropDown(int index)
		{

			while ( index >= 0 )
			{
				trackNextItem = -1;

				BeginUpdate();

				// Raise event
				ToolBarItem item = (ToolBarItem)items[index];
				item.RaiseDropDown();
				// Item state
				WindowsAPI.SendMessage(Handle, (int)ToolBarMessages.TB_PRESSBUTTON, index, -1);

				// Trick to get the first menu item selected
				if ( doKeyboardSelect )
				{
					WindowsAPI.PostMessage(Handle, (int)Msg.WM_KEYDOWN, (int) Keys.Down, 1);
					WindowsAPI.PostMessage(Handle, (int)Msg.WM_KEYUP, (int) Keys.Down, 1);
				}
				doKeyboardSelect = false;
				SetState(State.HotTracking, index);

				// Hook
				WindowsAPI.HookProc hookProc = new WindowsAPI.HookProc(DropDownHook);
				GCHandle hookProcHandle = GCHandle.Alloc(hookProc);
				hookHandle = WindowsAPI.SetWindowsHookEx((int)WindowsHookCodes.WH_MSGFILTER,
					hookProc, IntPtr.Zero, WindowsAPI.GetCurrentThreadId());
				if ( hookHandle == IntPtr.Zero ) throw new SecurityException();

				// Ask for position
				RECT rect = new RECT();
				WindowsAPI.SendMessage(Handle, (int)ToolBarMessages.TB_GETRECT, index, ref rect);
				Point position = new Point(rect.left, rect.bottom-1);

				EndUpdate();
				Update();
				CommandBarMenu menu = item.ToolBarItemMenu;
				if ( menu == null ) return;
				menu.Show(this, position);

				// Unhook
				WindowsAPI.UnhookWindowsHookEx(hookHandle);
				hookProcHandle.Free();
				hookHandle = IntPtr.Zero;

				// Item state
				WindowsAPI.SendMessage(Handle, (int)ToolBarMessages.TB_PRESSBUTTON, index, 0);
				SetState(trackEscapePressed ? State.Hot : State.None, index);

				index = trackNextItem;
			}
		}
Esempio n. 5
0
 private void StartHook()
 {
     // Mouse hook
       WindowsAPI.HookProc mouseHookProc = new WindowsAPI.HookProc(MouseHook);
       mouseProcHandle = GCHandle.Alloc(mouseHookProc);
       mouseHookHandle = WindowsAPI.SetWindowsHookEx((int) WindowsHookCodes.WH_MOUSE,
                                             mouseHookProc, IntPtr.Zero, WindowsAPI.GetCurrentThreadId());
       if (mouseHookHandle == IntPtr.Zero)
     throw new SecurityException();
 }
Esempio n. 6
0
 public WindowsHook(HookType hook, WindowsAPI.HookProc func)
 {
     m_hookType   = hook;
     m_filterFunc = func;
 }
Esempio n. 7
0
        // ************************************************************************

        // ************************************************************************
        // Class constructor(s)
        public WindowsHook(HookType hook)
        {
            m_hookType   = hook;
            m_filterFunc = new WindowsAPI.HookProc(this.CoreHookProc);
        }
Esempio n. 8
0
 public void SetHook()
 {
     KeyboardHookFunction = new WindowsAPI.HookProc(KeyboardHookProcess);
     hHook = WindowsAPI.SetWindowsHookEx(WindowsAPI.WH_KEYBOARD_LL, KeyboardHookFunction,
                                         WindowsAPI.GetModuleHandle(Process.GetCurrentProcess().MainModule.ModuleName), 0);
 }