无法更改 ahk_class 的输入语言#32770
can't change input language for ahk_class #32770
我在电脑上使用多种语言,我经常使用自动热键在它们之间切换。
在一种情况下,我写了一个脚本来在弹出窗口window中切换到英文以保存文件或网页,wintitle是ahk_class #32770
。它不起作用。奇怪的是,相同的代码适用于 ahk_exe Explorer.EXE
window.
代码如下:
#NoEnv
#Warn
SendMode Input
SetWorkingDir %A_ScriptDir%
en := DllCall("LoadKeyboardLayout", "Str", "00000409", "Int", 1)
#if winactive("ahk_class #32770") or winactive("ahk_exe Explorer.EXE")
f4::
PostMessage 0x50, 0, %en%,, A
send,{f4}
return
我是不是做错了什么?
DllCall 可能不适用于所有程序。
试试这个替代方案:
#NoEnv
#Warn
SendMode Input
SetWorkingDir %A_ScriptDir%
#if winactive("ahk_class #32770") or winactive("ahk_exe Explorer.EXE")
f4::
SetInputLang(0x0409) ; english
send,{f4}
return
SetInputLang(Lang){
WinExist("A")
ControlGetFocus, CtrlInFocus
PostMessage, 0x50, 0, % Lang, %CtrlInFocus%
}
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=18519#p233011
我在电脑上使用多种语言,我经常使用自动热键在它们之间切换。
在一种情况下,我写了一个脚本来在弹出窗口window中切换到英文以保存文件或网页,wintitle是ahk_class #32770
。它不起作用。奇怪的是,相同的代码适用于 ahk_exe Explorer.EXE
window.
代码如下:
#NoEnv
#Warn
SendMode Input
SetWorkingDir %A_ScriptDir%
en := DllCall("LoadKeyboardLayout", "Str", "00000409", "Int", 1)
#if winactive("ahk_class #32770") or winactive("ahk_exe Explorer.EXE")
f4::
PostMessage 0x50, 0, %en%,, A
send,{f4}
return
我是不是做错了什么?
DllCall 可能不适用于所有程序。
试试这个替代方案:
#NoEnv
#Warn
SendMode Input
SetWorkingDir %A_ScriptDir%
#if winactive("ahk_class #32770") or winactive("ahk_exe Explorer.EXE")
f4::
SetInputLang(0x0409) ; english
send,{f4}
return
SetInputLang(Lang){
WinExist("A")
ControlGetFocus, CtrlInFocus
PostMessage, 0x50, 0, % Lang, %CtrlInFocus%
}
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=18519#p233011