【问题标题】:can't change input language for ahk_class #32770无法更改 ahk_class 的输入语言 #32770
【发布时间】:2020-09-25 04:43:12
【问题描述】:

我在 PC 上使用多种语言,我经常使用自动热键在它们之间切换。

在一种情况下,我编写了一个脚本来在弹出窗口中切换到英文以保存文件或网页,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

我是不是做错了什么?

【问题讨论】:

    标签: autohotkey postmessage input-language


    【解决方案1】:

    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-20
      • 2014-11-15
      • 1970-01-01
      • 2013-07-18
      • 2021-12-20
      • 1970-01-01
      • 1970-01-01
      • 2013-12-29
      相关资源
      最近更新 更多