在AutoIt v3中有一个函数,称为HotKeySet。它设置了一个热键,在按下时调用用户功能。这是一个全系统热键,这意味着当热键被设置时,该键不能用于其他任何事情。如何在C系统中设置HotKey系统#
基本上,我想赶Esc键或其它键,像$
,`
等,当用户按下它的任何地方,甚至外面的应用程序,它应该让我知道。
例如,我会像循环内的HotKeySet({ESC})那样做,当它完成时,程序会等待该按键被按下。
public static void work() {
while (true) {
string task = null;
lock (locker)
if (tasks.Count > 0) {
task = tasks.Dequeue();
if (task == null) {
return;
}
}
if (task != null) {
//MessageBox.Show("Performing task: " + task);
Program.mainAnnounceWindow.setLogTextBox(task);
Program.mainAnnounceWindow.setLogTrayTip(task);
Program.windowStateChange("Show");
// Set the hotkey here
SetHotkey(`);
//Wait for hotkey to press when it's pressed... Execute some stuff
Thread.Sleep(5000); // Simulate work...
Program.windowStateChange("Hide");
}
else {
wh.WaitOne(); // No more tasks - wait for a signal
}
}
}
似乎它正是我所需要的:-)谢谢一堆! – MadBoy 2010-02-09 14:20:44