【发布时间】:2015-12-26 20:14:24
【问题描述】:
您好,我正在开发一个 C# Windows 应用程序,该应用程序在应用程序外部使用 CTRL+A 和 CTRL+Z 等组合键(在后台运行)。
我尝试了RegisterHotKeys 教程,但我遇到了问题。当按下 CTRL+A 时,只会执行我的方法,并且永远不会执行 Windows 默认操作。我想执行第一个 Windows 操作,并且仅在该操作之后执行该键的方法。
例如:
CTRL+A
1) Select All
2) My code
下面的一些代码:
private void mainForm_Load(object sender, EventArgs e)
{
ObjectsList = new List<Data>();
thisWindow = FindWindow(null, "myform");
RegisterHotKey(thisWindow, 1, (uint)fsKeyMod.Control, (uint)Keys.A);
}
private enum fsKeyMod
{
Control = 0x0002,
}
protected override void WndProc(ref Message keyPressed)
{
base.WndProc(ref keyPressed);
if (keyPressed.Msg == 0x0312)
{
Console.WriteLine("apasat cv...");
}
}
我需要尽快解决。 谢谢!
【问题讨论】:
-
您是否要重载全局键盘快捷键?如果是这种情况,请考虑根本不这样做。它将导致可以想象的最不友好的用户界面体验。
标签: c# winapi windows-api-code-pack registerhotkey