1

我在我的电脑上使用了几种语言,我经常使用自动热键在它们之间切换。

在一种情况下,我编写了一个脚本来在弹出窗口中切换到英文以保存文件或网页,wintitle 为ahk_class #32770. 它不起作用。奇怪的是相同的代码适用于ahk_exe Explorer.EXE窗口。

这是代码:

#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

我做错什么了吗?

4

1 回答 1

2

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

于 2020-09-25T11:28:31.650 回答