5

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}

Ciantic
  • 6,064
  • 4
  • 54
  • 49

2 Answers2

7

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.

Community
  • 1
  • 1
Robert Ilbrink
  • 7,738
  • 2
  • 22
  • 32
  • {Blind} seems to work nowadays with F keys. I have LWin mapped to F14 (with SharpKeys), then "F14 & n::Send, {Blind}^{n}" works as desired (Shift+Win+N -> Shift+Ctrl+N). – Lukas Rytz Oct 08 '21 at 18:56
0

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.

Anthony Raimondo
  • 1,621
  • 2
  • 24
  • 40
  • I tried that initially, I had a problem where alwaysoff was not alwaysoff, and sometimes the CapsLock triggered capslock anyway in some programs. Though F13 is not a silver bullet either, I sometimes find that it types the letter if I type multiple F13 shortcuts in a conjunction. I wish I could just modify the keyboard driver in lower level, even in hardware level inside keyboard. – Ciantic Feb 19 '16 at 11:07