Tag: registerhotkey

RegisterHotKeys和全局键盘钩子?

什么是RegisterHotKeys和全局键盘钩子,它们如何工作? 我想制作一个关键,专注于我的应用程序的Form(当它被最小化时),然后专注于一个文本框,所以从我读过的我需要使用RegisterHotKeys函数(这是一个更好的解决方案,我的需要),但我找不到如何或在哪里可以选择我自己的键(只有一个键 – ESC ),然后命令它专注于我的表单,然后在文本框上。

如何禁用user32.dll中的系统热键?

如果它是相关的,我用C#编码。 我正在尝试为自助服务终端应用程序禁用系统热键。 此处使用的代码来自: https : //www.codeproject.com/kb/cs/kiosk_cs.aspx?display = print 此个人: 如何在单击鼠标左键时禁用按住Alt键,按住Control键和Shift键,似乎已成功使用此方法在Windows上禁用Alt + F4 。 但是她没有明确指出她使用的Windows版本,而不是说其中一个命令在W8中不起作用。 那些不懂代码的人教程: https : //www.youtube.com/watch?v = qQWqGOaZiFI 我尝试过这个。 RegisterHotKey(this.Handle, int 1, (int)USE_ALT, (int)Keys.F4); ^但仍然失败。 Marshal.GetLastWin32Error().ToString() 当^运行时,它返回错误代码“1400” 。 枚举错误: https ://msdn.microsoft.com/en-us/library/windows/desktop/ms681385( v = vs.85).aspx。 这表明这是“窗口句柄无效”的结果。 。 我不知道为什么这是因为“Alt + F4”关闭当前所选窗口。 我很确定FindWindow(string cls, string wndwText)返回的是什么。 我添加了“SetLastError = true” : [DllImport(“user32.dll”, SetLastError = true)] private static […]

在.NET中注册热键 – 三/四键的组合

我被困。 现在,我使用以下代码来收听热键: [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); protected override void WndProc(ref Message m) { if (m.Msg == 0x0312) { // whatever i need } base.WndProc(ref m); } 和这个注册热键的function: Form1.RegisterHotKey(this.Handle, this.GetType().GetHashCode(), 0, (int)chr); 它完美地运作。 我的问题是如何将多个热键注册为相同的组合,例如: A + B + […]

使用RegisterHotKey注册多个热键

我找到了这段代码来注册一个热键: [DllImport(“user32.dll”)] public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vlc); protected override void WndProc(ref Message m) { if (m.Msg == 0x0312) MessageBox.Show(“Hotkey pressed”); base.WndProc(ref m); } public FormMain() { InitializeComponent(); //Alt + A RegisterHotKey(this.Handle, this.GetType().GetHashCode(), 1, (int)’A’); } 它工作得很好,但我的问题是我想使用两个不同的快捷方式。 我知道第二个参数是id,所以我想我可以创建一个不同的id并在WndProc函数中添加一个新的if语句,但我不知道我会怎么做。 简而言之,我将如何创建第二个快捷方式? 谢谢,

使用RegisterHotKey检测Ctrl + V但不截取它

我需要检测用户何时按下Ctrl + V (无论窗口焦点如何 – 我的应用程序可能会被最小化)但我不能停止实际的粘贴操作。 我尝试了一些事情:(我成功绑定了RegisterHotKey的键击) 我有: protected override void WndProc(ref Message m) { if (m.Msg == 0x312) hotKey(); base.WndProc(ref m); } 我尝试过以下方法: void hotKey() { SendKeys.SendWait(“^v”); //just puts ‘v’ instead of clipboard contents } 和 void hotKey() { SendKeys.SendWait(ClipBoard.GetText()); /* This works, but since Ctrl is still down, it triggers * all the […]

更改其他进程的键盘布局

我正在用C#编写一个在后台运行的程序,并允许用户使用热键在活动窗口中切换键盘布局。 (Windows仅支持CTRL + SHIFT和ALT + SHIFT ) 我正在使用RegisterHotKey来捕获热键,它运行正常。 问题是我找不到任何API来改变聚焦窗口的键盘布局。 ActivateKeyboardLayout和LoadKeyboardLayout只能更改调用线程的键盘布局。 有谁知道如何更改不同线程的键盘布局(语言栏的方式)?