问题
; 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?
回答1:
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/
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
Here it is in one line:
<!d::Send , % "^#{" . (( flag := !flag ) ? "right" : "left" ) . "}"
I didn't know it was possible to put all that in one line, so I learned something today. :D
来源:https://stackoverflow.com/questions/54170938/autohotkey-script-changes-input-language-how-to-avoid-this