Reputation: 1533
Pressing or holding a modifier key (without pressing another) triggers a keyboard shortcut:
~LControl::
keyWait,LControl,t0.1
if !errorLevel
Sendinput, ^{Space} ; open command pallete
else{
KeyWait, LControl
if (A_PriorKey="LControl")
SendInput, ^{f} ; ope find bar
}
return
~lalt::
keyWait,lalt,t0.1
if !errorLevel
Sendinput, ^{f1} ; open color pallete
else{
KeyWait, lalt
if (A_PriorKey="lalt")
SendInput, ^{f2} ; ope search bar
}
return
It works with any modifier key except lalt
that triggers the Windows menu bar. I tried holding F2 so it thinks I pressed another key with Alt which does not work:
~lalt::
!{blind}{f22 down} ; this shortcut is not bound to a command
keyWait,lalt,t0.1
if !errorLevel
Sendinput, ^{f1} ; open color pallete
else{
KeyWait, lalt
!{blind}{f22 up} ; this shortcut is not bound to a command
if (A_PriorKey="lalt")
SendInput, ^{f2} ; ope search bar
}
return
I need the "~" prefix to see if a modifier key is down for operations like Ctrl + left click + drag.
Upvotes: 1
Views: 65
Reputation: 10603
To prevent Alt triggering the menu bar permanently use
~LAlt::Send {Blind}{vkE8}
See MenuMaskKey
In this case
~lalt::
Send {Blind}{vkE8}
keyWait,lalt,t0.1
if !errorLevel
Sendinput, ^{f1} ; open color pallete
else{
KeyWait, lalt
if (A_PriorKey="lalt")
SendInput, ^{f2} ; ope search bar
}
return
Untested.
Upvotes: 1