zoukankan      html  css  js  c++  java
  • C# SetWindowsHookEx

      [DllImport("user32.dll")]
            static extern IntPtr SetWindowsHookEx(int idHook, keyboardHookProc callback, IntPtr hInstance, uint threadId);
    
            /// <summary>
            /// 安装钩子
            /// </summary>
            /// <param name="idHook">钩子类型 13键盘和14鼠标,用来对底层输入事件监视</param>
            /// <param name="callback">函数指针</param>
            /// <param name="hInstance">包含SetWindowsHookEx函数的模块地址,user32.dll入口</param>
            /// <param name="threadId">0表示系统钩子,</param>
            /// <param name="str"></param>
            /// <returns></returns>
            public IntPtr SetWindowsHookEx(int idHook, keyboardHookProc callback, IntPtr hInstance, uint threadId, string str = "占位符")
            {
                return SetWindowsHookEx(idHook, callback, hInstance, threadId);
            }
         public event KeyEventHandler KeyDown;
            private void button7_Click(object sender, EventArgs e)
            {
                this.KeyDown += new KeyEventHandler(gkh_KeyDown); //绑定事件
                Keys key = (Keys)1;
                KeyEventArgs kea = new KeyEventArgs(key);
                KeyDown(this, kea);
            }
            private void gkh_KeyDown(object sender, KeyEventArgs e)
            {
                MessageBox.Show("000111");
            }
  • 相关阅读:
    HTML5 JSDOM
    svn 基本操作
    Flex布局
    git上传布置代码 git优势
    jsonp, json区别
    require.js 模块化简单理解
    @vue/cli 3 安装搭建及 webpack 配置
    npm 常用命令 使用命令删除 node_modules 包
    package.json字段分析
    rem适配方案
  • 原文地址:https://www.cnblogs.com/enych/p/10334869.html
Copyright © 2011-2022 走看看