Skip to content

Instantly share code, notes, and snippets.

@aaaddress1
Created June 2, 2021 13:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaaddress1/1e429c226b0a1af3b404d16d28699f6b to your computer and use it in GitHub Desktop.
Save aaaddress1/1e429c226b0a1af3b404d16d28699f6b to your computer and use it in GitHub Desktop.
swich IME (Input Method Editor) to Zh-TW chinese on specific window
// [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