Created
June 2, 2021 13:26
-
-
Save aaaddress1/1e429c226b0a1af3b404d16d28699f6b to your computer and use it in GitHub Desktop.
swich IME (Input Method Editor) to Zh-TW chinese on specific window
This file contains 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
// [Experiment] swich IME to Traditional Chinese | |
// $ g++ -m32 -static inputLockToZhTW.cpp && a | |
// test on League of Legends (TW) client, but got ignored :( | |
// by aaaddress1@chroot.org | |
#include <windows.h> | |
#include <iostream> | |
int main(void) { | |
for (char buf[64]; ; Sleep(150)) { | |
GetWindowTextA(GetForegroundWindow(), buf, sizeof(buf)); | |
// once found that LOL client is on the top, and send IME change requests | |
if (strstr(buf, "League of Legends")) SendMessageW( | |
GetForegroundWindow(), | |
WM_INPUTLANGCHANGEREQUEST, | |
0, | |
(LPARAM)LoadKeyboardLayoutW(/* zw_tw */ L"00000404", KLF_ACTIVATE) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment