AutoHotKey脚本更改了输入语言,如何避免这种情况? [英] AutoHotKey script changes input language, how to avoid this?
问题描述
; switch between virtual desktops (win10)
; supposed to be launched in initial desktop
flag := 0
LAlt & D::
if(flag = 0){
send, {Control Down} {LWin Down} {Right} {Control Up} {LWin Up}
flag := 1
Return
}
else{
send, {Control Down} {LWin Down} {Left} {Control Up} {LWin Up}
flag := 0
Return
}
应用后,有机会显示语言栏,甚至更改输入语言.请问对此有何建议?
when applied, there are chances to show the Language Bar and even change the input language. Any advice on this, please?
推荐答案
虽然我不能确定为什么打开语言栏,但本文介绍了如何禁用语言栏的内置热键: https://winaero.com/blog/change-hotkeys-switch-keyboard-layout-windows-10/
While I can't say for sure why it opens the language bar, this article shows how to disable the built-in hotkeys for the language bar: https://winaero.com/blog/change-hotkeys-switch-keyboard-layout-windows-10/
您的代码也可能存在一些小问题.括号之间似乎有空隙;Send命令将发送那些空格.当然,我不希望这会导致您遇到的问题.
There may be some minor issues with your code as well. It looks like there are spaces between your braces; the Send command will send those spaces. Of course, I wouldn't expect that this would cause the problems you're experiencing.
这是您的代码的精简版,可能表现得更好:
Here's a condensed version of your code that may possibly behave better:
<!d::
flag := !flag
If flag
Send , ^#{right}
Else
Send , ^#{left}
Return
以下是使用三元运算符的精简版本:
Here's an even more condensed version using the ternary operator:
<!d::
sKeyName := ( flag := !flag ) ? "right" : "left"
Send , ^#{%sKeyName%}
Return
这里是一行:
<!d::Send , % "^#{" . (( flag := !flag ) ? "right" : "left" ) . "}"
我不知道是否可以将所有内容放在一起,所以今天我学到了一些东西.:D
I didn't know it was possible to put all that in one line, so I learned something today. :D
这篇关于AutoHotKey脚本更改了输入语言,如何避免这种情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!