我被困.
现在,我使用以下代码来收听热键:
[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);
}
Run Code Online (Sandbox Code Playgroud)
和这个注册热键的功能:
Form1.RegisterHotKey(this.Handle, this.GetType().GetHashCode(), 0, (int)chr);
Run Code Online (Sandbox Code Playgroud)
它完美地运作.我的问题是如何将多个热键注册为相同的组合,例如:
编辑:我发现(如Zooba所说)如何"解密"发送了哪个热键,这是解决方案:
protected override void WndProc(ref Message m)
{
if (m.Msg == …Run Code Online (Sandbox Code Playgroud)