gpt4 book ai didi

autohotkey - 切换键盘布局有效但不总是

转载 作者:行者123 更新时间:2023-12-01 04:25:56 26 4
gpt4 key购买 nike

我对 Autohotkey 有点陌生。

我安装了 3 种语言,其中一种我很少使用。所以我只想使用 WIN+Space 在 2 种语言 (EN-RU) 之间切换。
我在网上搜索了简短且逻辑上接近我需要的代码,我做了一些修改以使其更像对象和个性化条件。
代码:全选 - 展开 View

#Space::
SetFormat, Integer, H
Lang := { "EN" : "0x4090409" , "RU" : "0x4190419", "HE": "0x40D040D" }

WinGet, WinID,, A
ThreadID:=DllCall("GetWindowThreadProcessId", "Int", WinID, "Int", "0")
InputLocaleID:=DllCall("GetKeyboardLayout", "Int", ThreadID)

if(InputLocaleID=Lang.RU OR InputLocaleID=Lang.HE)
SendMessage, 0x50,, % Lang.EN,, A
else if(InputLocaleID=Lang.EN)
SendMessage, 0x50,, % Lang.RU,, A
Exit

它适用于大多数程序,但很少有它只能切换到 RU。

运行良好:Chrome、notePad、notePad++、Notion、VScode、Android Studio、IntelliJ IDEA、
不工作:OneNote Windows 10 应用程序(即使在 Onenote 2016 中它也能正常工作)

如果有人可以帮助我,我将不胜感激。
提前致谢!

最佳答案

相关解答 Autohotkey Forum

  #Space:: ;  Switch keyboard (EN-RU)

Lang := { "EN": 0x4090409, "RU": 0x4190419 }
; For compatibility with UWP apps, get the thread of the focused
; control, not the active window. This is necessary because those
; apps are hosted within a window owned by a different process.
ControlGetFocus Focused, A
ControlGet CtrlID, Hwnd,, % Focused, A
; Using Ptr vs. Int vs. UInt won't matter in these cases
ThreadID := DllCall("GetWindowThreadProcessId", "Ptr", CtrlID, "Ptr", 0)
; HKL is a handle type (64-bit on x64)
InputLocaleID := DllCall("GetKeyboardLayout", "UInt", ThreadID, "Ptr")

if (InputLocaleID != Lang.EN)
SendMessage, 0x50,, % Lang.EN,, ahk_id %CtrlID%
else
SendMessage, 0x50,, % Lang.RU,, ahk_id %CtrlID%
Exit

关于autohotkey - 切换键盘布局有效但不总是,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58658619/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com