1

How do I allow the Hotstrings to be triggered by remapped hotkeys so they work in Autohotkey?

r::Send e
::ee::by the way

So that when I press rr on the keyboard it prints "by the way".

Currently it prints that only when pressing ee.

NOTE: I'd like a solution that doesn't involve assigning multiple triggering abbreviations to expand to the same string.

  • You gave your own answer, just repeat the last line and use rr instead of ee..... – Robert Ilbrink Sep 5 '14 at 14:59
  • @RobertIlbrink I have multiple keys assigned to the same key it seems like there might be a better way. Basically I have reassigned the entire keyboard to a different keyboard layout. – William Sep 7 '14 at 3:38
  • it's not direct answer, but I suggest you to create new layout using e.g. msdn.microsoft.com/en-us/goglobal/bb964665.aspx instead of re-mapping all keys with AutoHotkey. It's way more effective, and less ambiguous. – LogicDaemon Sep 9 '14 at 16:58
  • That doesn't work for a large set of keys in addition many applications have there shortcuts assigned from keycode so you have to reassign the key using autohotkey to get it to work properly – William Sep 11 '14 at 15:29
  • Why not store by the way as a variable and send it when rr or ee is pressed? – NonlinearFruit Feb 2 '17 at 14:20
2

You can use #InputLevel if you use AHK v1.1+ http://ahkscript.org/docs/commands/_InputLevel.htm

::ee::by the way
#InputLevel, 1
r::Send e
0

Use this instead:

r::Send {ASC 0101}
::ee::by the way
::rr::by the way
  • I dont understand your answer it doesnt seem to work for what I was intending. I would like to avoid typing the different keyboard hotstrings. – William Sep 7 '14 at 13:00
  • What this does is send the ASCII code for "e" when you press "r". On pressing "r" twice successively and hitting the space bar, it expands to "by the way". The same thing happens when you press "e" twice in succession and hit the space bar. – Vinayak Sep 7 '14 at 15:49
  • @LiamWilliam what doesn't seem to work? Are you not getting "by the way" when you type "ee" or "rr" and hit space/enter/period? – Vinayak Sep 7 '14 at 16:35
  • yes but I dont want to have to redefine the keys two times – William Sep 7 '14 at 16:36
  • You might want to edit your question to specify that. – Vinayak Sep 7 '14 at 16:49
0

Here is a code:

r::
Loop
{
    b:=GetKeyState("r")
    if (b !=1)
    {
        ccounter := 1
        Loop
        {
            c:=GetKeyState("r")
            if (c=1)
            {
                MsgBox, by the way
                return
            }
            Sleep, 50

            ccounter:= ccounter + 1

            if (ccounter = 60)
            {
                return
            }
        }
    }
}
return

It will pop message box "by the way" when r is pressed 2 times. But time between 2 r presses should be maximum 3 seconds. You can adjust that time by changing ccounter = 60 . Each value there equals to 50 milliseconds (1000 milliseconds = 1 second).

Also, always use AutoHotkey and its documenatation from http://ahkscript.org/ (current uptodate version, new official website)! AutoHotkey and its documentation from autohotkey.com is outdated and you may have some problems using them!

  • Your script completely hijacks the r key. I assume the OP doesn't want that. From what I understand, the OP wants the r key to send e when pressed. And when either ee or rr is typed, it must expand to "by the way". – Vinayak Sep 8 '14 at 14:11
  • @Vinayak For removing r hijacking just replace r:: with ~r::. If he wants other things, it will be nice if will tell what exactly he needs from script. – vasili111 Sep 8 '14 at 14:40
  • I believe it is quit clear as is. – William Sep 11 '14 at 13:37
0

Using an * with the hotstring means that it won't wait for a space/tab character before substituting. This also allows multiple hotstrings to share a single definition.

r::Send e

:*:ee::
:*:rr::
  Send by the way
  Return
-2

This will work:

:*:rr::  
Goto ::ee  
return  
::ee::  
Send by the way  
return
  • 1
    Can you explain how and why it will work? Please see How to Answer and take our tour. – Burgi Feb 2 '17 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.