[英]Global Hotkey does not work in Fullscreen game
I am creating a program for taking screenshots of a game, out of the game. 我正在创建一个程序,用于从游戏中获取游戏的屏幕截图。 When I press the hotkey it works, but with the open game in fullscreen it does not detect the key.
当我按下热键时,它可以工作,但是在全屏打开游戏的情况下,它无法检测到该键。
My code: 我的代码:
protected override void WndProc(ref Message m)
{
const int WM_HOTKEY = 0x0312;
switch (m.Msg)
{
case WM_HOTKEY:
{
if ((short)m.WParam == 1)
{
start = DateTime.Now;
progressBar1.Maximum = 1;
progressBar1.Step = 1;
progressBar1.Value = 0;
DoRequest();
}
break;
}
default:
{
base.WndProc(ref m);
break;
}
}
}
I register the global key using: 我使用以下命令注册全局密钥:
RegisterHotKey(this.Handle, 1, (int)KeyModifier.None, Keys.F11);
Help-me :/ 帮我 :/
SOLVED! 解决了! Resolved, I managed to fix through this project: http://www.codeproject.com/Articles/19004/A-Simple-C-Global-Low-Level-Keyboard-Hook
解决后,我设法解决了这个项目: http : //www.codeproject.com/Articles/19004/A-Simple-C-Global-Low-Level-Keyboard-Hook
Thank you all! 谢谢你们!
The problem with most games (not all of them) is that they use DirectInput (DirectX) and not windows message pump to read keystrokes. 大多数游戏(不是全部)的问题在于它们使用DirectInput(DirectX),而不是Windows消息泵来读取按键。 I have also written an application using voice recognition that sends keys to games and experienced the same issue which I solved by looking at DirectX keycodes.
我还编写了一个使用语音识别的应用程序,该应用程序将键发送给游戏,并且遇到了我通过查看DirectX键码解决的相同问题。 ref: DirectInput
参考:DirectInput
我有一个类似的问题,但是我通过使用管理员权限运行程序来解决了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.