Press "e" once, some activity, twice another

Get help with using AutoHotkey and its commands and hotkeys
Lumens
Posts: 4
Joined: 02 Feb 2017, 07:35

Press "e" once, some activity, twice another

02 Feb 2017, 07:44

Hi everyone

I need

e:: ; once - any activity /FOR EXAMPLE
Run calc

e and e again :: ; another
Run notepad

Is it possible? Maybe, waiting some milliseconds in the first one, and others in the second one.
enter8
Posts: 96
Joined: 05 May 2016, 16:48

Re: Press "e" once, some activity, twice another

02 Feb 2017, 11:01

This opens calc with a single press of 'e', and it opens calc and notepad if 'e' is pressed twice within 300 milliseconds. Not quite what you asked for, but should be enough to get you started.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Lumens
Posts: 4
Joined: 02 Feb 2017, 07:35

Re: Press "e" once, some activity, twice another

02 Feb 2017, 11:46

Thank you! It works.
But unfortunately, when I press twice, It produces both actions.
Do you have any idea how can I improve it?
guest3456
Posts: 2051
Joined: 09 Oct 2013, 10:31

Re: Press "e" once, some activity, twice another

02 Feb 2017, 13:18

you could probably use the A_TimeSincePriorHotkey built in variable

but this was easy enough:

Code: [Select all] [Download] GeSHi © Codebox Plus

e::
Input, NextKey, L1 T0.5
if (NextKey = "e")
Run, notepad
else
Run, calc
return


User avatar
jeeswg
Posts: 2637
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Press "e" once, some activity, twice another

02 Feb 2017, 15:39

I've been curious to write a double-tap hotkey, because I haven't done one before.
This method is flexible for any hotkey.
I like the Input approach because it is more elegant, however,
it might be fiddly to get it to work with certain hotkeys.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Lumens
Posts: 4
Joined: 02 Feb 2017, 07:35

Re: Press "e" once, some activity, twice another

02 Feb 2017, 15:49

Thank you everyone!

As ever, AHK has many options to resolve our wishes

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Hellbent and 37 guests