Can I specify a maximum time between two consecutive hothey keys

Get help with using AutoHotkey and its commands and hotkeys
User avatar
guivho
Posts: 6
Joined: 09 Mar 2017, 08:59
Facebook: guivho
Google: guivho
GitHub: guivho

Can I specify a maximum time between two consecutive hothey keys

03 Aug 2020, 12:19

Based on several suggestions in this forum (thanks everyone), I use following code to facilitate entry of accented spanish characters et al (cfr infra). Basically I enter a vowel followed by a ' to produce the accented vowel. It would be nice if these key pairs would only trigger if entered within a preset maximum time: entering e.g. a followed by ' with some extra delay between the two keys would then produce a' rather than á
I have searched the help file and the forums, but did not find how this could be achieved
:*?:a'::{U+00E1} ; á
:*?:e'::{U+00E9} ; é
:*?:i'::{U+00ED} ; í
:*?:o'::{U+00F3} ; ó
:*?:u'::{U+00FA} ; ú
:*?:c'::{U+00E7} ; ç
:*?:n'::{U+00F1} ; ñ
:*?:!'::{U+00A1} ; ¡
:*?:?'::{U+00BF} ; ¿
:*?:''::' ; '
:*?:\\::\ ; \

Any suggestion and/or help would be highly appreciated,
Guido
User avatar
flyingDman
Posts: 847
Joined: 29 Sep 2013, 19:01

Re: Can I specify a maximum time between two consecutive hothey keys

03 Aug 2020, 14:52

Try this:

Code: Select all

~a::
~e::
Input, x, L1 T0.2,`'                                ; set timeout ; here 0.2 seconds
if (errorlevel = "EndKey:'")
	switch A_ThisHotkey
		{
		case "~a" : send {bs}á						; or {bs}{U+00E1}
		case "~e" : send {bs}é
		}
return
I am lazy, I only wrote it for a and e but can include all your special characters.
User avatar
guivho
Posts: 6
Joined: 09 Mar 2017, 08:59
Facebook: guivho
Google: guivho
GitHub: guivho

Re: Can I specify a maximum time between two consecutive hothey keys

05 Aug 2020, 08:07

I could not get that to work,but it triggered following solution:
:B0 C*?:e::
Input, OutputVar, L1 T.5, {SC056}'"^
if (ErrorLevel = "EndKey:sc056")
send {bs}{U+00E8}
else if (ErrorLevel = "EndKey:'")
send {bs}{U+00E9}
else if (errorlevel = "EndKey:""")
send {bs}{u+00EB}
else if (errorlevel = "EndKey:^")
send {bs}{u+00EA}
return

This works fine for ê, é, è and ë but it eats any non-endkey character that is typed within the interval. So if yoy rapidly type 'peach' you end up with 'pach' which makes this approach unacceptable...
A pluspoint is that one can use a keyname as an endkey (see https://www.autohotkey.com/boards/viewtopic.php?f=76&t=79433)
User avatar
flyingDman
Posts: 847
Joined: 29 Sep 2013, 19:01

Re: Can I specify a maximum time between two consecutive hothey keys

05 Aug 2020, 11:48

Make sure you have the latest version of AHK. Switch Case is not supported by vesions before [v1.1.31+].

Return to “Ask For Help”

Who is online

Users browsing this forum: mikeyww, RyConnMD, Xtra and 55 guests