C++ 如何截取Ctrl Shift alt组合的消息 非MFC

来源:百度知道 编辑:UC知道 时间:2024/05/30 01:35:12
我想要做个类似QQ 的热键···但是老是不能同时响应这3个键的组合··有什么方法吗?谢谢

完成这一功能的最简单方法是使用RegisterHotKey函数。在调用该函数后你的进程回在ctrl + alt + del 按下时比系统先得到通知。 你需要处理的消息是WM_HOTKEY。

BOOL RegisterHotKey(HWND hWnd, int id, UINT fsModifiers, UINT vk);
参数 fsModifiers指明与热键联合使用按键,可取值为:MOD_ALT MOD_CONTROL MOD_WIN MOD_SHIFT
参数 vk指明热键的虚拟键码
The RegisterHotKey function defines a system-wide hot key.

Syntax

BOOL RegisterHotKey( HWND hWnd,
int id,
UINT fsModifiers,
UINT vk
);
Parameters

hWnd
[in] Handle to the window that will receive WM_HOTKEY messages generated by the hot key. If this parameter is NULL, WM_HOTKEY messages are posted to the message queue of the calling thread and must be processed in the message loop.
id
[in] Specifies the identifier of the hot key. No other hot key in the calling thread should have the same identifier. An application must specify a value in the range 0x0000 through 0xBFFF