Using Global Hotkeys
使用熱鍵
參考 Beginner's Tutorial - Using global hotkeys
- Register HotKey
HWND hWnd, // window to receive hot-key notification int id, // identifier of hot key UINT fsModifiers, // key-modifier flags UINT vk // virtual-key code ); //ex1 : ATL+SHIFT+P RegisterHotKey(hWndA, 100, MOD_ALT | MOD_SHIFT, 'P'); //ex2: WIN+R RegisterHotKey(hWndA, 200, MOD_WIN, 'R');
注意:若註冊已存在之熱鍵,此函數會傳回 false - Handling the hot key
LRESULT OnHotKey(WPARAM wParam, LPARAM lParam); //wParam = identifier
- Un-registering hotkeys
HWND hWnd, // window associated with hot key int id // identifier of hot key );