0
; 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 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.