Last active
March 29, 2025 15:36
-
-
Save maokwen/4d99f5c0aa2e7c0c114c708b03fb73ae to your computer and use it in GitHub Desktop.
AutoHotKey 锁定微软拼音中英文切换
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 %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) | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
这个脚本有各种问题,建议参考这里的版本:https://gist.github.com/pernalin9/220d00016182acb7f13b96cd0506c0a9?permalink_comment_id=5155221#gistcomment-5155221