Last active
October 28, 2015 07:23
-
-
Save foreverbell/21bbb9e431648e9e189c to your computer and use it in GitHub Desktop.
在 Windows8 里重映射 <Ctrl-Space> 快捷键以实现切换输入法功能。设置开机自动启动即可。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Windows.h> | |
#include <Winuser.h> | |
int APIENTRY wWinMain(_In_ HINSTANCE hInstance, | |
_In_opt_ HINSTANCE hPrevInstance, | |
_In_ LPTSTR lpCmdLine, | |
_In_ int nCmdShow) { | |
RegisterHotKey(NULL, 1, MOD_CONTROL, VK_SPACE); | |
MSG msg; | |
while (GetMessage(&msg, NULL, 0, 0) != 0) { | |
if (msg.message == WM_HOTKEY) { | |
keybd_event(VK_LWIN, 0, KEYEVENTF_EXTENDEDKEY, 0); | |
keybd_event(VK_SPACE, 0, KEYEVENTF_EXTENDEDKEY, 0); | |
keybd_event(VK_LWIN, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); | |
keybd_event(VK_SPACE, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); | |
} else { | |
TranslateMessage(&msg); | |
DispatchMessage(&msg); | |
} | |
} | |
return (int) msg.wParam; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment