简体   繁体   中英

How can I keep modifier of hotkey active in AutoHotkey?

A media keyboard I'm using doesn't have a full set of keys, so I'm trying to map alternatives using AutoHotkey. Basically, I want to use the Alt Gr key together with some other keys to simulate the missing keys. This is what I've done:

<^>!,::send {Home}
<^>!.::send {End}
<^>![::send {PrintScreen}
<^>!]::send {Insert}

However, if I want to do the equivalent of Shift + Home (to select all text to the beginning of a line), this doesn't work as I'd hoped. I know I can put a * at the beginning of the line so that Home is still sent even when I'm holding Shift , but the problem is that I'd like the Shift key to still be active so that I get the equivalent of Shift + Home .

Likewise, if I want to do Alt + Print Screen then holding Alt while pressing Alt Gr + [ doesn't have the desired effect.

I assume I could set up extra rules to catch those combinations, but surely there must be a way to just have AutoHotkey not discard whatever modifier I'm holding at the time I hit the hotkey so that whatever combination I use it'll work?

EDIT (2014-07-16):

Here is the latest version of my script, which includes comments that make it clear what I'm wanting to achieve. Everything in this script works except for the last line. For some reason, even though I'm trying to send Alt + PrtScn it gets treated as just PrtScn.

; Home ( by pressing AltGr + , )
<^>!,::send {Home}
; Shift + Home ( by pressing Shift + AltGr + , )
+<^>!,::send +{Home}

; End ( by pressing AltGr + . )
<^>!.::send {End}
; Shift + End ( by pressing Shift + AltGr + . )
+<^>!.::send +{End}

; Insert ( by pressing AltGr + [ )
<^>![::send {Insert}
; Shift + Insert ( by pressing Shift + AltGr + [ )
+<^>![::send +{Insert}

; PrtScn ( by pressing AltGr + ] )
<^>!]::send {PrintScreen}
; Alt + PrtScn ( by pressing LeftAlt + AltGr + ] )
<!<^>!]::send !{PrintScreen}

Using the {Blind} attribute will pass on the modifier keys.

eg

<^>!,::send {Blind}{Home}

See: Send existing modifiers with a key in autohotkey?

It turns out that some of the combinations I wanted to do with Autohotkey, involving the AltGr key, are not possible due to AltGr itself actually being a combination of Control and Right Alt . Therefore, not all modifiers are available for use together with that key, and some of the AutoHotkey commands give unwanted/unexpected results when trying to use them together with AltGr .

The final version of the script I'm using with my new keyboard (the UK version of the Microsoft All-in-One Media Keyboard) is as follows:

; Set an initial state for the lock keys
SetCapsLockState, off
SetNumLockState, on
SetScrollLockState, off

; Home ( by pressing AltGr + , )
<^>!,::send {Home}
; Shift + Home ( by pressing Shift + AltGr + , )
+<^>!,::send +{Home}

; End ( by pressing AltGr + . )
<^>!.::send {End}
; Shift + End ( by pressing Shift + AltGr + . )
+<^>!.::send +{End}

; Insert ( by pressing AltGr + [ )
<^>![::send {Insert}
; Shift + Insert ( by pressing Shift + AltGr + [ )
+<^>![::send +{Insert}

; PrtScn ( by pressing AltGr + ] )
<^>!]::send {PrintScreen}
; Alt + PrtScn ( by pressing Alt + ] )
!]::send !{PrintScreen}

; Scroll Lock ( by pressing AltGr + \ )
<^>!\::send {ScrollLock}

; Pause/Break ( by pressing AltGr + p )
<^>!p::send {Pause}
; Win + Pause/Break ( by pressing Shift + Alt + p )
+!p::send #{Pause}
; Control + Pause/Break ( by pressing Shift + Ctrl + p )
+^p::send ^{CtrlBreak}

; Run Calculator ( by pressing AltGr + c )
<^>!c::Run Calc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM