How to remap: {CTRL down}{a down}{CTRL up}{a up} :: F2 Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Sandro_spb
Posts: 23
Joined: 05 Oct 2021, 15:22

How to remap: {CTRL down}{a down}{CTRL up}{a up} :: F2

13 Oct 2021, 02:36

have key on keyboard that sends: {CTRL down}{a down}{CTRL up}{a up} . How to remap this sequence as F2?
.
.
Spoiler
Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to remap: {CTRL down}{a down}{CTRL up}{a up} :: F2

13 Oct 2021, 03:11

Hallo,
try:

Code: Select all

$^a::
Send, {a Up}
Hotkey, *a, Return, On
KeyWait, Ctrl
IF GetKeyState("a","P")
{
	KeyWait, a
	Send, {F2}
}
Else
	Send, ^a
Hotkey, *a, Return, Off
Return:
Return
Sandro_spb
Posts: 23
Joined: 05 Oct 2021, 15:22

Re: How to remap: {CTRL down}{a down}{CTRL up}{a up} :: F2

13 Oct 2021, 14:10

Still works as Ctrl+A, but gives other output:

Code: Select all

A2  01D	 	d	12.91	LControl       	
41  01E	h	d	0.00	a              	
A2  01D	i	u	0.00	LControl       	
41  01E	i	u	0.00	a              	
A2  01D	i	d	0.03	LControl       	
A2  01D	 	u	0.05	LControl       	
41  01E	s	u	0.00	a              	
A2  01D	i	d	0.01	LControl       	
41  01E	i	d	0.00	a              	
41  01E	i	u	0.00	a              	
A2  01D	i	u	0.02	LControl   
Have any idea?
Sandro_spb
Posts: 23
Joined: 05 Oct 2021, 15:22

Re: How to remap: {CTRL down}{a down}{CTRL up}{a up} :: F2

13 Oct 2021, 17:27

How to use elapsed time to catch this sequence of "a"? It's every time = 0
Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to remap: {CTRL down}{a down}{CTRL up}{a up} :: F2

14 Oct 2021, 03:11

Here with above script,
{CTRL down}{a down}{CTRL up}{a up}
VK SC Type Up/Dn Elapsed Key Window
-------------------------------------------------------------------------------------------------------------
A2 01D d 8.89 LControl Unbenannt - Editor
41 01E h d 0.28 a
A2 01D i u 0.00 LControl
41 01E i u 0.00 a
A2 01D i d 0.02 LControl
A2 01D u 0.26 LControl
41 01E h d 0.23 a
41 01E h d 0.05 a
41 01E h d 0.03 a
41 01E h d 0.03 a
41 01E s u 0.03 a
71 03C i d 0.02 F2
71 03C i u 0.00 F2

Press [F5] to refresh.

{CTRL down}{a down}{a up}{CTRL up}
VK SC Type Up/Dn Elapsed Key Window
-------------------------------------------------------------------------------------------------------------
5B 15B i d 0.66 LWin Unbenannt - Editor
A0 02A i d 0.00 LShift
27 14D i d 0.02 Right
27 14D i u 0.02 Right
5B 15B i u 0.03 LWin
A0 02A i u 0.01 LShift
FF 000 i d 0.02 ^
FF 000 i u 0.02 ^
A2 01D d 4.44 LControl
41 01E h d 0.41 a
A2 01D i u 0.00 LControl
41 01E i u 0.00 a
A2 01D i d 0.02 LControl
41 01E s u 0.16 a
A2 01D u 0.16 LControl
A2 01D i d 0.01 LControl
41 01E i d 0.00 a
41 01E i u 0.00 a

A2 01D i u 0.03 LControl
Press [F5] to refresh.

Here is another method:

Code: Select all

$^a::
Hotkey, *a, Return, On
KeyWait, a
Hotkey, *a, Return, Off
KeyWait, Ctrl
Send,% (TCtrl < TA)?"{F2}":"^a"
Return:
Return
~*Ctrl Up::TCtrl := A_TickCount
~*a Up::TA := A_TickCount
Sandro_spb
Posts: 23
Joined: 05 Oct 2021, 15:22

Re: How to remap: {CTRL down}{a down}{CTRL up}{a up} :: F2

14 Oct 2021, 05:43

Cant undrstand why, but not working. Here is history:

A2 01D d 9.13 LControl
41 01E h d 0.00 a
A2 01D h u 0.05 LControl
41 01E h u 0.00 a
A2 01D i d 0.00 LControl
41 01E i d 0.00 a
41 01E i u 0.00 a
A2 01D i u 0.01 LControl
Sandro_spb
Posts: 23
Joined: 05 Oct 2021, 15:22

Re: How to remap: {CTRL down}{a down}{CTRL up}{a up} :: F2  Topic is solved

14 Oct 2021, 05:54

Great! Now it works. Just added "=" in Send. Thank you very much!

Code: Select all


$^a::
Hotkey, *a, Return, On
KeyWait, a
Hotkey, *a, Return, Off
KeyWait, Ctrl
Send,% (TCtrl <= TA)?"{F2}":"^a"
Return:
Return
~*Ctrl Up::TCtrl := A_TickCount
~*a Up::TA := A_TickCount

Sandro_spb
Posts: 23
Joined: 05 Oct 2021, 15:22

Re: How to remap: {CTRL down}{a down}{CTRL up}{a up} :: F2

16 Oct 2021, 13:38

One more questuon: when ctrl+A is pressed how to get delay between ctrl down and A down?
Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to remap: {CTRL down}{a down}{CTRL up}{a up} :: F2

17 Oct 2021, 02:10

I do not understand the question.
1. which ctrl+A ? The one that triggers the hotkey or the one that sends the script?
2. should the size of the delay be captured for evaluation or should the delay be increased?
Sandro_spb
Posts: 23
Joined: 05 Oct 2021, 15:22

Re: How to remap: {CTRL down}{a down}{CTRL up}{a up} :: F2

17 Oct 2021, 06:29

1. That triggers the hotkey or when pressing Ctrl+A
2. It should be captured

Now I try to get rid of delay when pressing Ctrl+A.

Before, when pressed Ctrl+A - selecting starts before releasing the keys, now after keys are Up. If can fix this - that will be brilliant!
Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to remap: {CTRL down}{a down}{CTRL up}{a up} :: F2

17 Oct 2021, 06:56

Before, it didn't matter if Ctrl or A were released first.
Now it does matter, i.e. Autohotkey must wait for the keys to be released.
For decision making, releasing only one of the keys is enough, optimize the script accordingly!
Sandro_spb
Posts: 23
Joined: 05 Oct 2021, 15:22

Re: How to remap: {CTRL down}{a down}{CTRL up}{a up} :: F2

17 Oct 2021, 07:14

Great idea! I'll try it! Thank you very much!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Billykid, dinodragon, mcd and 165 guests