Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Create additional modifier keys


  • Please log in to reply
6 replies to this topic
dsavant
  • Members
  • 562 posts
  • Last active: May 23 2016 01:14 AM
  • Joined: 04 Aug 2009
Hello,

Is there a way to turn a normally non-modifier key into a modifier key to trigger AHK commands?

For example, my current modifier keys (as far as I know) are Shift, Alt, Ctrl and Win. Suppose I want to begin using my Pause/Break key (which I seldom use for anything) as an additional modifier -- i.e. so that I can use key combos such as the following to function as hotkeys:

Pause+1
Pause+2
Pause+F1
Pause+F2
and so on...

in the same way I can currently use Shift, Alt, Ctrl, etc:

Shift+1
Alt+2
Ctrl+F1
Ctrl+F2

Is that possible?
If so, how is it done?

Thanks
"A person who has never made a mistake is a person who has never tried anything new." ~Albert Einstein
"Any fool can make things larger and more complex. It takes a touch of genius...to move in the opposite direction." ~Albert Einstein

  • Guests
  • Last active:
  • Joined: --
Custom Combinations and Other Features

TLM
  • Administrators
  • 3864 posts
  • Last active:
  • Joined: 21 Aug 2006
1 & Pause::msg()

2 & Pause::msg()

F1 & Pause::msg()

F2 & Pause::msg()

; etc etc...

msg(){

  msgbox % "You pressed " a_thisHotkey

}

Posted Image

don't duplicate, iterate!


sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010
What a helpful guest :)

To add some helpfulness to dsavant:

Pause & W::MsgBox You pressed Pause+W!
Pause::Send {Pause}.

Elegant, right?

I was a bit curious about how to achieve this myself, since some people - for unknown reasons - have, euhm, "unique" wishes for hotkey combinations. My father wanted to hotkey the webpage that shows tv-times to the hotkey combination t+v, for example. :)

The problem with an implementation that easy would of course be that one of those keys lost their normal push-down-behaviour (and instead send their corresponding text on key release). Is there any way to get around that?

EDIT:

~t & v::
Send {backspace} ; Added so that the "TV" combo doesn't produce a T
MsgBox Wanna see some TV?
return

Not-so-elegant with the backspace. "Regret last sent key", any better way to do it? Else I'd have to design a solution based upon active window class, I guess.

dsavant
  • Members
  • 562 posts
  • Last active: May 23 2016 01:14 AM
  • Joined: 04 Aug 2009
Thanks for response

1 & Pause::msg()
2 & Pause::msg()
F1 & Pause::msg()
F2 & Pause::msg()
; etc etc...


This seems backwards from my question but I do appreciate you showing me what

"Key1 & Key2::..."

can do.

Thanks
"A person who has never made a mistake is a person who has never tried anything new." ~Albert Einstein
"Any fool can make things larger and more complex. It takes a touch of genius...to move in the opposite direction." ~Albert Einstein

dsavant
  • Members
  • 562 posts
  • Last active: May 23 2016 01:14 AM
  • Joined: 04 Aug 2009

Pause & W::MsgBox You pressed Pause+W!
Pause::Send {Pause}.

Thanks a bunch sumon! That's the 2nd great reply you have given me today. It works just as I need and does not render the involved keys unusable as was the case above. I also appreciate the:

Pause::Send {Pause}

line. I don't know if I would have figured that out.

One more thing: because of paralysis in both of my hands, I benefit tremendously by the Sticky Keys option in Windows. Is there a way to work that into the code you shared?

Thanks again.
"A person who has never made a mistake is a person who has never tried anything new." ~Albert Einstein
"Any fool can make things larger and more complex. It takes a touch of genius...to move in the opposite direction." ~Albert Einstein

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010
You're welcome, thanks for the appreciation. To me it seems like the Askforhelp forum is the more active at the moment, and since I am currently out of scriptinginspiration I forumlurk, I bet.

Anyway, I think you'd need some special solution to accomodate for your hands. Hotkeys and paralyzis doesn't sound too sweet. It's actually weird that stickyness isn't more supported, as I think most of us could use it for the hardtoreach-combos.

$Pause:: ; The § should prevent Pause from triggering itself
KeyWait, W, D T3 ; T3 gives you three seconds to press W
if (Errorlevel)
  Send {Pause} ; By the way, this is really just necessary if you wanna preserve the original pause functionality
else
  MsgBox You pressed Pause+W!
return

From KeyWait