Tag: global hotkey

C#中使用全局热键进行密钥捕获

我有一个在后台运行的应用程序,就像我可以将我的应用程序保存在系统托盘中。如果它仍然在系统托盘上,我的应用程序将完成它的工作。 每当用户按F10或F9时,将完成一些工作。 我试过这个: public partial class Form1 : Form { public int a = 1; [DllImport(“user32.dll”)] public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vlc); [DllImport(“user32.dll”)] public static extern bool UnregisterHotKey(IntPtr hWnd, int id); [DllImport(“User32.dll”)] private static extern short GetAsyncKeyState(System.Windows.Forms.Keys vKey); [DllImport(“User32.dll”)] private static extern short GetAsyncKeyState(System.Int32 vKey); const int MYACTION_HOTKEY_ID = […]

在不聚焦窗口的情况下捕获键

我有一个应用程序,总是检查是否按下了像F12这样的键。 它不需要关注我的应用程序的主窗口。 我试过这段代码: public int a = 1; // DLL libraries used to manage hotkeys [DllImport(“user32.dll”)] public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vlc); [DllImport(“user32.dll”)] public static extern bool UnregisterHotKey(IntPtr hWnd, int id); const int MYACTION_HOTKEY_ID = 1; public Form1() { InitializeComponent(); // Modifier keys codes: Alt = 1, Ctrl = […]