Skip to content

Instantly share code, notes, and snippets.

@maokwen
Last active March 29, 2025 15:36
Show Gist options
  • Select an option

  • Save maokwen/4d99f5c0aa2e7c0c114c708b03fb73ae to your computer and use it in GitHub Desktop.

Select an option

Save maokwen/4d99f5c0aa2e7c0c114c708b03fb73ae to your computer and use it in GitHub Desktop.
AutoHotKey 锁定微软拼音中英文切换
#Include %A_ScriptDir%
timeInterval := 500
; +-------------------------+-------------------------+
; | SubLanguage ID | Primary Language ID |
; +-------------------------+-------------------------+
; 15 10 9 0 bit
InChs() {
ime_status := DllCall("GetKeyboardLayout", "int", 0, "UInt")
return (ime_status & 0xffff) = 0x804 ; LANGID(Chinese) = 0x804
}
SwitchImeState(id) {
SendMessage(0x283, ; WM_IME_CONTROL
0x002, ; wParam IMC_SETCONVERSIONMODE
1025, ; lParam (Chinese)
, ; Control (Window)
id)
}
DetectHiddenWindows True
SetTimer Mainloop, 1000
MainLoop() {
try {
hWnd := WinGetID("A")
id := DllCall("imm32\ImmGetDefaultIMEWnd", "Uint", hWnd, "Uint")
if (InChs()) {
SwitchImeState(id)
}
}
}
@maokwen
Copy link
Author

maokwen commented Mar 7, 2024

@kwbd 谢谢,脚本已经更新

@maokwen
Copy link
Author

maokwen commented Nov 17, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment