hotkey.cs

来自「语音视频功能 里面实现了基本的QQ与语音对话」· CS 代码 · 共 29 行

CS
29
字号
using System;
using System.Runtime.InteropServices;

namespace gowk.common
{
	public class HotKey
	{
		public const int WH_KEYBOARD=2;
		// 安装钩子
		[DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
		public static extern int SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId);

		// 卸载钩子
		[DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
		public static extern bool UnhookWindowsHookEx(int idHook);

		// 继续下一个钩子

		[DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
		public static extern int CallNextHookEx(int idHook, int nCode, Int32 wParam, IntPtr lParam);  

		// 取得当前线程编号

		[DllImport("kernel32.dll")]
		static extern int GetCurrentThreadId(); 
	}
	public delegate int HookProc(int nCode, Int32 wParam, IntPtr lParam);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?