Reputation: 143
language = de
~Alt & Shift::
~Shift & Alt::
if (language == "de") {
language = en
}
else {
language = de
}
msgbox % language
Return
This is the code Im working on, binding a work to Alt+Shift. But I wanna preserve the default behavior of Alt+Shift which seems to be disabled after this code runs.
Any Ideas?
Upvotes: 1
Views: 1085
Reputation: 10852
Use ~Alt & ~Shift::
instead of ~Alt & Shift::
.
The tilde ~
prefix makes a hotkey keep its original function. As far as I understand,
~Alt & Shift::msgbox
could be translated into the following:
~Alt:: ; Alt enables the detection of a shift press
hotkey, Shift, shift, ON ; OVERRIDES the normal shift behavior, not keeping it (~Shift)
hotkey, Shift up, shiftUp, ON
return
shift:
msgBox
return
shiftUp:
hotkey, Shift, shift, OFF
hotkey, Shift up, shiftUp, OFF
return
. Alt
is a hotkey and Shift
also is one, being activated on Alt
pressure. But that very Shift
hotkey overwrites any normal shift behaviour.
So, alt & shift
is actually two different hotkeys combined to one. Each of them needs to be prefixed with its own options.
My solution works with another concurring AutoHotkey script. But it seems not with the windows built-in hotkey shift+alt
aka alt+shift
. Even if the ahk hotkey trigger looks like that
~Alt & ~Shift::
, this will STILL override the usual behavior which is Window's language switching mechanism. I do not know the reason behind it, maybe someone else does? I can only think of a (fairly simple) workaround:
~Alt & ~Shift::
send {alt down}{shift}{alt up}
; (your other actions)
return
In this case, you might even want to remove the ~
's in order to prevent confusion.
Upvotes: 2