Tente isso
; Switch keyboard layout, only if RAlt was pressed alone:
RAlt up::
If (A_PriorKey = "RAlt")
Send {Alt down}{Shift down}{Shift up}{Alt up} ; switch keyboard layout
return
; In this case its necessary to define a custom combination by using "&" or ">!"
; to avoid that RAlt loses its original function as a modifier key:
>!a:: Send !a ; >! means RAlt