Implementing sequence of two or more shortcuts Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AndrewKun
Posts: 24
Joined: 03 Jun 2015, 12:03

Implementing sequence of two or more shortcuts

11 Aug 2020, 03:21

Hey,

I'm trying to implement the following approach to launching frequently used apps/web sites in two steps:

1. I press some shortcut that enables jump state, e.g. Win+J
2. Then I press a specific key to run the command I need.

This works sort of like a lead key in vim.

I know I can do something like:

Code: Select all

jump_state := 0

#j:: jump_state := 1

$g::
    if (jump_state = 1) {
        run https://www.google.com
        jump_state := 0
    }
    else {
        Send, g
    }
    return
Which is very sub-optimal due to "g" key being evaluated every single press. Maybe there's a better way to do this?
Rohwedder
Posts: 7608
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Implementing sequence of two or more shortcuts  Topic is solved

11 Aug 2020, 05:03

Hallo,
try:

Code: Select all

jump_state := 0

#j:: jump_state := 1

#If jump_state
g::
run https://www.google.com
jump_state := 0
return
#If
Or perhaps:

Code: Select all

jump_state := 0

#j:: jump_state := 1

#If jump_state And jump_state-- ;see ShortCircuit
g::run https://www.google.com
a::run https://www.autohotkey.com/boards/viewforum.php?f=76
#If
https://www.autohotkey.com/docs/Functions.htm#ShortCircuit
AndrewKun
Posts: 24
Joined: 03 Jun 2015, 12:03

Re: Implementing sequence of two or more shortcuts

11 Aug 2020, 09:25

@Rohwedder

This is perfect, thank you so much!

Now I have almost unlimited number of shortcuts without conflicting with Windows global shortcuts, and this approach also solves the conflict with other layouts. :dance:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 228 guests