Two-part hotkey

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AHKxx
Posts: 75
Joined: 26 Feb 2014, 01:37

Two-part hotkey

03 Oct 2015, 12:38

I would like to create a hotkey where a key combination is pressed, but nothing happens unless and until another specific key is pressed. Basically, the equivalent of what in Microsoft Word would be a macro trigger like: Alt+s,s

I know that's possible, or at least I think it is, but I'm not seeing how to do it.

Thanks.
twoparts

Re: Two-part hotkey

03 Oct 2015, 12:53

There are various solutions, see "CHORDING / MORSE-CODE" at http://www.autohotkey.net/~faqbot/typing-scripts.html - the problem is that not all the links work but if you Google the title between "" e.g. "Detect Ctrl+K followed by Ctrl+P by transforming Ctrl-characters" you should find the correct post on ahk . com - try the link first, if it fails search for it.
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Two-part hotkey

03 Oct 2015, 13:02

Try this:

Code: Select all

!s::
If !(A_PriorHotkey=A_ThisHotkey && A_TimeSincePriorHotkey<300)
  return
MsgBox Hotkey !ss
return
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: Two-part hotkey

03 Oct 2015, 13:14

what about this?

Code: Select all

!s::
   Input, key, L1
   if (key = "s")
      msgbox, you pressed Alt+S and then S
   else if (key = "x")
      msgbox, you pressed Alt+S and then X
   ;//etc
return

AHKxx
Posts: 75
Joined: 26 Feb 2014, 01:37

Re: Two-part hotkey

03 Oct 2015, 13:37

guest3456 wrote:what about this?

Code: Select all

!s::
   Input, key, L1
   if (key = "s")
      msgbox, you pressed Alt+S and then S
   else if (key = "x")
      msgbox, you pressed Alt+S and then X
   ;//etc
return
Thank you. This works nicely as written.

But when I comment out the first msgbox, and put in the commands I want to send, it immediately sends the Alt-s to focused application (which I don't mind overriding) rather than waiting for the second keypress. The keys I want to send to the focused app are:

Code: Select all

Send {LEFT 1}s{RIGHT 1} 
Also, is there a way to make it time out, and/or to send all keys not otherwise specified directly to the app as though typed regularly?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: roysubs and 286 guests