美文网首页
WPF添加Hook

WPF添加Hook

作者: 雪之梦_8f14 | 来源:发表于2019-07-22 17:27 被阅读0次

实现代码

const int WM_MOUSEMOVE = 0x0200;

private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
            source.AddHook(WndProc);
        }

 private static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            switch (msg)
            {
                case WM_MOUSEMOVE:
                    Console.WriteLine("Mouse Move");
                    break;
                default:
                    break; 
            }

            return IntPtr.Zero;
        }

相关文章

网友评论

      本文标题:WPF添加Hook

      本文链接:https://www.haomeiwen.com/subject/ggnwlctx.html