Beispiel #1
0
 /// <summary>
 /// Install low level mouse hook
 /// </summary>
 public void Install()
 {
     hookHandler    = HookFunc;
     mouseHookID    = SetHook(hookHandler, WH_MOUSE_LL);
     keyHookHandler = KeyBoardHookFunc;
     keyBoardHookID = SetHook(keyHookHandler, WH_KEYBOARD_LL);
 }
Beispiel #2
0
 /// <summary>
 /// Sets hook and assigns its ID for tracking
 /// </summary>
 /// <param name="proc">Internal callback function</param>
 /// <returns>Hook ID</returns>
 private IntPtr SetHook(MouseHookHandler proc)
 {
     using (ProcessModule module = Process.GetCurrentProcess().MainModule)
     {
         return(SetWindowsHookEx(WH_MOUSE_LL, proc, GetModuleHandle(module.ModuleName), 0));
     }
 }
Beispiel #3
0
        /// <summary>
        /// マウスフック開始
        /// </summary>
        public void Start()
        {
            if (!IsStarted)
            {
                hookHandler = HookFunc;
                hookID      = SetHook(hookHandler);

                IsStarted = true;
            }
        }
Beispiel #4
0
        /// <summary>
        ///     Install low level mouse hook
        /// </summary>
        public void Install()
        {
            if (_isInstalled)
            {
                return;
            }

            _hookHandler = HookFunc;
            _hookId      = SetHook(_hookHandler);
            _isInstalled = true;
        }
Beispiel #5
0
        private void OnWindowSystemMouseClick(MouseHookHandler.MouseType type)
        {
            IntPtr hld       = SelectWindowHandler.WindowFromPoint();
            string titleName = WindownTitleHandler.GetWindowTitle(hld);

            SetWindowNameLabel(titleName);
            if (type == MouseHookHandler.MouseType.LeftUp)
            {
                curSelectWindowHld = hld;
                MouseHookHandler.HookStop();
            }
        }
Beispiel #6
0
        /// <summary>
        /// Install low level mouse hook
        /// </summary>
        /// <param name="mouseHookCallbackFunc">Callback function</param>
        public void Install()
        {
            hookHandler = HookFunc;
            hookID      = SetHook(hookHandler);

            if (mouseHistory == null)
            {
                mouseHistory = new ObservableCollection <string>();
            }

            supressNext = false;
        }
Beispiel #7
0
        //-----------------------------------------------------
        // フック開始/終了
        //-----------------------------------------------------

        // キー入力とマウス入力をフック
        public void Hook()
        {
            IntPtr hMod = Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0]);

            UnhookWindowsHookEx(mouseHook);
            UnhookWindowsHookEx(keyHook);
            mouseHandler = new MouseHookHandler(OnMouseLLHook);
            keyHandler   = new KeyHookHandler(OnKeyLLHook);
            mouseHook    = SetWindowsHookEx(WH.MOUSE_LL, mouseHandler, hMod, 0);
            keyHook      = SetWindowsHookEx(WH.KEYBOARD_LL, keyHandler, hMod, 0);

            if (mouseHook == IntPtr.Zero || keyHook == IntPtr.Zero)
            {
                UnhookWindowsHookEx(mouseHook);
                UnhookWindowsHookEx(keyHook);
                int errorCode = Marshal.GetLastWin32Error();
                Console.WriteLine(new Win32Exception(errorCode));
            }
        }
Beispiel #8
0
        //-----------------------------------------------------
        // フック開始/終了
        //-----------------------------------------------------

        // キー入力とマウス入力をフック
        public void Hook()
        {
            IntPtr hMod = Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0]);

            UnhookWindowsHookEx(mouseHook);
            UnhookWindowsHookEx(keyHook);
            mouseHandler = new MouseHookHandler(OnMouseLLHook);
            keyHandler = new KeyHookHandler(OnKeyLLHook);
            mouseHook = SetWindowsHookEx(WH.MOUSE_LL, mouseHandler, hMod, 0);
            keyHook = SetWindowsHookEx(WH.KEYBOARD_LL, keyHandler, hMod, 0);

            if (mouseHook == IntPtr.Zero || keyHook == IntPtr.Zero)
            {
                UnhookWindowsHookEx(mouseHook);
                UnhookWindowsHookEx(keyHook);
                //                int errorCode = Marshal.GetLastWin32Error();
                //                Console.WriteLine(new Win32Exception(errorCode));
                hooking = false;
            }
            else
            {
                hooking = true;
            }
        }
Beispiel #9
0
 /// <summary>
 /// Install low level mouse hook
 /// </summary>
 /// <param name="mouseHookCallbackFunc">Callback function</param>
 public void Install()
 {
     hookHandler = HookFunc;
     hookID      = SetHook(hookHandler);
 }
Beispiel #10
0
 /// <summary>
 /// Sets hook and assigns its ID for tracking
 /// </summary>
 /// <param name="proc">Internal callback function</param>
 /// <returns>Hook ID</returns>
 private IntPtr SetHook(MouseHookHandler proc)
 {   
     using (ProcessModule module = Process.GetCurrentProcess().MainModule)
         return SetWindowsHookEx(WH_MOUSE_LL, proc, GetModuleHandle(module.ModuleName), 0);
 }        
Beispiel #11
0
 public void Install()
 {
     this.hookHandler = new MouseHookHandler(this.HookFunc);
     this.hookID      = this.SetHook(this.hookHandler);
 }
Beispiel #12
0
 private static extern IntPtr SetWindowsHookEx(int idHook,
                                               MouseHookHandler lpfn, IntPtr hMod, uint dwThreadId);
Beispiel #13
0
		/// <summary>
		/// Install low level mouse hook
		/// </summary>
		/// <param name="mouseHookCallbackFunc">Callback function</param>
		public void Install() {
			hookHandler = HookFunc;
			hookID = SetHook(hookHandler);
			IsHooked = true;
		}
Beispiel #14
0
 private void OnClickSelectWindowBtn(object sender, RoutedEventArgs e)
 {
     MouseHookHandler.HookStart(OnWindowSystemMouseClick);
 }
Beispiel #15
0
 public static extern IntPtr SetWindowsHookEx(short idHook,
                                              MouseHookHandler hookProc,
                                              IntPtr hMod, // HINSTANCE
                                              uint dwThreadId);
Beispiel #16
0
 /// <summary>
 /// Install low level mouse hook
 /// </summary>
 /// <param name="mouseHookCallbackFunc">Callback function</param>
 public void Install()
 {
     hookHandler = HookFunc;
     hookID      = SetHook(hookHandler);
     IsActive    = true;
 }
Beispiel #17
0
 /// <summary>
 /// Install low level mouse hook
 /// </summary>
 /// <param name="mouseHookCallbackFunc">Callback function</param>
 public void StartHooking()
 {
     hookHandler = HookFunc;
     hookID      = SetHook(hookHandler);
 }
 /// <summary>
 ///     Sets hook and assigns its ID for tracking
 /// </summary>
 /// <param name="proc">Internal callback function</param>
 /// <returns>Hook ID</returns>
 private static IntPtr SetHook(MouseHookHandler proc)
 {
     using (var module = Process.GetCurrentProcess().MainModule)
         return(InternalSetWindowsHookEx(WhMouseLl, proc, NativeMethods.GetModuleHandle(module.ModuleName), 0));
 }
Beispiel #19
0
 /// <summary>
 /// Sets hook and assigns its ID for tracking
 /// </summary>
 /// <param name="proc">Internal callback function</param>
 /// <param name="handle">Handle for resource (keyboard or mouse?)</param>
 /// <returns>Hook ID</returns>
 static IntPtr SetHook(MouseHookHandler proc, int handle)
 {
     using (ProcessModule module = Process.GetCurrentProcess().MainModule)
         //return NativeMethods.SetWindowsHookEx(handle, proc, NativeMethods.GetModuleHandle(module.ModuleName), 0);
         return(NativeMethods.SetWindowsHookEx(handle, proc, IntPtr.Zero, 0));
 }
Beispiel #20
0
 static extern IntPtr SetWindowsHookEx(WH hookType, MouseHookHandler hookDelegate, IntPtr module, uint threadId);
Beispiel #21
0
 /// <summary>
 /// Install low level mouse hook
 /// </summary>
 public void Install()
 {
     _hookHandler = HookFunc;
     _hookId      = SetHook(_hookHandler);
 }
Beispiel #22
0
 private static extern IntPtr SetWindowsHookEx(int idHook,
     MouseHookHandler lpfn, IntPtr hMod, uint dwThreadId);
Beispiel #23
0
 static extern IntPtr SetWindowsHookEx(WH hookType, MouseHookHandler hookDelegate, IntPtr module, uint threadId);
Beispiel #24
0
 /// <summary>
 /// Install low level mouse hook
 /// </summary>
 /// <param name="mouseHookCallbackFunc">Callback function</param>
 public void Install()
 {
     hookHandler = HookFunc;
     hookID = SetHook(hookHandler);
 }
Beispiel #25
0
 /// <summary>
 ///     Sets hook and assigns its ID for tracking
 /// </summary>
 /// <param name="proc">Internal callback function</param>
 /// <returns>Hook ID</returns>
 private static IntPtr SetHook(MouseHookHandler proc)
 {
     using (var module = Process.GetCurrentProcess().MainModule)
         return InternalSetWindowsHookEx(WhMouseLl, proc, NativeMethods.GetModuleHandle(module.ModuleName), 0);
 }