检测系统范围内的击键 [英] Detecting a keystroke system-wide

查看:102
本文介绍了检测系统范围内的击键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C ++的新手,我正在尝试制作一个程序来自动执行某些任务。当我点击ctrl时,我想用函数调用生成一个新线程 - 但是我在查找如何获得ctrl - 检查时遇到了一些麻烦。我查看了GetKeyState
,但似乎只看了一个键。我不知道如何继续这一点,任何帮助将不胜感激

Hi, I'm pretty new to C++ and am trying to make a program to automate some tasks. I want to spawn a new thread with a function call when I hit ctrl - but I am having some trouble figuring out how to get the ctrl - check. I looked at GetKeyState but it seems to only look at a single key. I'm not sure how to proceed with this and any help would be greatly appreciated

推荐答案

尝试此序列:

   RegisterHotKey(hwnd,1,
MOD_CONTROL |
MOD_NOREPEAT
VK_SUBTRACT );

   RegisterHotKey(hwnd,2,
MOD_CONTROL |
MOD_NOREPEAT
VK_OEM_MINUS );

 

< span lang ="EN-GB"style ="margin:0px"> 其中
hwnd HWND 你的窗口。该窗口将收到
WM_HOTKEY 通知。

where hwnd is HWND of your window. The window will receive the WM_HOTKEY notification.

如果您没有窗口,请参阅
hwnd NULL
< span style ="color:#0563c1"> https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-registerhotkey

If you do not have a window, see the example where hwnd is NULL: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-registerhotkey.


这篇关于检测系统范围内的击键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆