在Windows 10上从Alt + Shift切换周期中排除输入语言


3

我的系统上有3种语言:英语,俄语和日语。但是我只希望能够在英语和俄语之间进行Alt + Shift。在W10中有办法吗?

这个问题在这里不适用,因为它不适用于W10。


您能解释为什么 Windows上的Alt + Shift / Ctrl + Shift切换循环中排除输入语言似乎不适用吗?看起来像是完全重复。
斯科特(Scott)

@Scott对于Windows 7,我找不到任何方法可以在W10上从该问题复制答案。
Liburia

1
确定,  编辑您的问题以解释该问题。
斯科特,

Answers:


1

请按照以下步骤操作:

  1. 安装AutoHotkey
  2. 创建一个文本文件并粘贴以下文本:
; 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}
  1. 保存并重命名带有.ahk扩展名的文件(例如,“排除Extra Keyboard Layouts.ahk”)
  2. 双击运行脚本。现在,Alt + Shift应该只在前两个键盘布局之间切换。

如果满意,可以编译脚本(右键单击->编译)以创建.exe文件。然后将.exe.ahk文件移动到启动文件夹(打开RUN并键入“ shell:startup ”,不带引号)。

附加说明:

  • 如果您复制.exe文件,则不再需要AutoHotkey,因此可以将其卸载。
  • 如果复制.ahk脚本文件,则不得卸载AutoHotkey。
  • 这篇文章解决了一个类似的问题,帮助提出了这个想法。

0

我建议使用相同的自动热键解决方案可能会稍微好一些。

与其切换到以前的布局(可能是第三个),不如禁用本机的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
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.