问题
I'm trying to send pressed modifiers with the Send command, only way I come up with is listing them all:
; (Note: I've remapped using registry the Capslock as F13)
F13 & h::
if GetKeyState("Control") && GetKeyState("Shift") {
Send +^{Left}
return
}
if GetKeyState("Control") {
Send ^{Left}
return
}
if GetKeyState("Shift") {
Send +{Left}
return
}
Send {Left}
return
In Windows if you press ctrl+left it jumps a word left, if I press ctrl+shift+left it selects a word leftwise. Similarily I'd like to send the existing modifiers as in above example, but is there a simpler way? Pseudocode: F13 & h::Send {CurrentlyPressedModifiers}{Left}
回答1:
You can do this with the Send, {Blind} mode. Example:
*a::Send, {Blind}{Left}
The *
accepts all modifiers for a and {Blind} passes the modifiers on to the Send
command.
Alternatively, you can avoid Send and use:
a::Left
Here all modifiers are automatically passed on to the Left
command.
Note: As far as I see after testing, neither solution will work with "your" combination keys, only with standard hotkeys.
So your initial solution might be the only one, unless you change the combination keys back to standard hotkeys.
回答2:
I know this is an old post but id like to share my script that applys to this problem.
SetCapsLockState, alwaysoff
CapsLock & i::send {Blind}{Up}
CapsLock & k::send {Blind}{Down}
CapsLock & j::send {Blind}{Left}
CapsLock & l::send {Blind}{Right}
CapsLock & n::send {Blind}{Home}
CapsLock & m::send {Blind}{End}
CapsLock & u::send {Blind}{BS}
CapsLock & o::send {Blind}{Del}
Capslock is disabled and holding it down maps the arrows keys in to i,j,k,l. The {Blind} allows for modifiers.
Home, End, Backspace and Delete are also remapped for much quicker typing.
来源:https://stackoverflow.com/questions/15380171/send-existing-modifiers-with-a-key-in-autohotkey