-
-
Save pernalin9/220d00016182acb7f13b96cd0506c0a9 to your computer and use it in GitHub Desktop.
微软输入法自动跳转为中文Fix.ahk
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
# 如果可以接受capslock作为输入法切换按键,强烈建议使用评论区脚本 | |
# 如果可以接受capslock作为输入法切换按键,强烈建议使用评论区脚本 | |
# 如果可以接受capslock作为输入法切换按键,强烈建议使用评论区脚本 | |
#Include %A_ScriptDir% | |
timeInterval := 500 | |
; +-------------------------+-------------------------+ | |
; | SubLanguage ID | Primary Language ID | | |
; +-------------------------+-------------------------+ | |
; 15 10 9 0 bit | |
InChs(hWnd) { | |
ThreadID:=DllCall("GetWindowThreadProcessId", "UInt", hWnd, "UInt", 0) | |
ime_status := DllCall("GetKeyboardLayout", "int", ThreadID, "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 | |
outer: | |
Loop { | |
try { | |
hWnd := WinGetID("A") | |
id := DllCall("imm32\ImmGetDefaultIMEWnd", "Uint", hWnd, "Uint") | |
if (InChs(hWnd)) { | |
SwitchImeState(id) | |
} | |
} catch as e { | |
; ^Esc 开始菜单弹窗,会卡死在找不到当前窗口 | |
continue("outer") | |
} | |
Sleep(timeInterval) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Lone101245 原本脚本在我的windows上确实可以运行,请再检查一下脚本是否一致。
不过原本版本的脚本确实存在很多小问题,我还发现这种连续调用SendMessage的方式在某些设备会造成cpu异常占用
我目前更改了一下脚本,如果可以接受的话建议使用这个版本(虽然还是会有一些偶发的小bug)
该版本特征:
该版本需要的操作:
该版本运行逻辑
使用两个月以来遇到的问题
具体代码