Answers:
请按照以下步骤操作:
; This scripts changes the functionality of Shift + Alt from "switch keyboard layout" ; to "change to previous layout". ; this is usefull when you have more than 2 keyboard layouts and want to switch between ; only 2 of them. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. LAlt & LShift::send, #^{space down}{space up}
如果满意,可以编译脚本(右键单击->编译)以创建.exe文件。然后将.exe或.ahk文件移动到启动文件夹(打开RUN并键入“ shell:startup ”,不带引号)。
附加说明:
我建议使用相同的自动热键解决方案可能会稍微好一些。
与其切换到以前的布局(可能是第三个),不如禁用本机的Alt + Shift循环热键并为自己的布局切换逻辑让路,这更好。
并使用以下脚本,可能会进行所需的调整:
#SingleInstance force
SendMode Input
; Cycled list of language ids
; refer to https://docs.microsoft.com/en-us/windows/win32/intl/language-identifiers
; and https://docs.microsoft.com/en-us/windows/win32/intl/language-identifier-constants-and-strings
; for finding out correct values
; in this case 0x409 means standard US English, and 0x419 means standard Russian
AltShiftLangs := [0x0409, 0x0419]
; 0x411 means japanese IME
CtrlAltLang := 0x0411
; This returns currently active language id
GetKeyboardLayout() {
WinGet, WinID,, A
ThreadID:=DllCall("GetWindowThreadProcessId", "UInt", WinID, "UInt", 0)
return DllCall("GetKeyboardLayout", "UInt", ThreadID, "UInt") & 0xFFFF
}
; This sends request to change system language to lang argument
SetKeyboardLayout(lang) {
PostMessage, 0x50,, lang,, A
}
; This returns 0-based index of Value in Arr
IndexOf(Arr, Value) {
Loop % Arr.Length()
if Arr[A_Index] == Value {
return A_Index-1
}
return -1
}
; This sets language based on current system lanuage and next value by index in Arr
; If current language is not found, it sets system to first language from Arr
SetNextLanguage(Arr) {
lang := GetKeyboardLayout()
idx := IndexOf(Arr, lang)
if (idx < 0) {
SetKeyboardLayout(Arr[1])
return
}
nextIdx := mod(idx+1, Arr.Length())
next := Arr[nextIdx+1]
SetKeyboardLayout(next)
}
; Alt+Shift hotkey - cycle between AltShiftLangs
LAlt & LShift::
SetNextLanguage(AltShiftLangs)
return
; Ctrl+Alt hotkey - switch directly to isolated CtrlAltLang
LCtrl & LAlt::
SetKeyboardLayout(CtrlAltLang)
return