Page 1 of 1

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

Posted: 13 Oct 2021, 02:36
by Sandro_spb
have key on keyboard that sends: {CTRL down}{a down}{CTRL up}{a up} . How to remap this sequence as F2?
.
.
Spoiler

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

Posted: 13 Oct 2021, 03:11
by Rohwedder
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

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

Posted: 13 Oct 2021, 14:10
by Sandro_spb
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?

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

Posted: 13 Oct 2021, 17:27
by Sandro_spb
How to use elapsed time to catch this sequence of "a"? It's every time = 0

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

Posted: 14 Oct 2021, 03:11
by Rohwedder
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

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

Posted: 14 Oct 2021, 05:43
by Sandro_spb
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

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

Posted: 14 Oct 2021, 05:54
by Sandro_spb
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


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

Posted: 16 Oct 2021, 13:38
by Sandro_spb
One more questuon: when ctrl+A is pressed how to get delay between ctrl down and A down?

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

Posted: 17 Oct 2021, 02:10
by Rohwedder
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?

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

Posted: 17 Oct 2021, 06:29
by Sandro_spb
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!

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

Posted: 17 Oct 2021, 06:56
by Rohwedder
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!

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

Posted: 17 Oct 2021, 07:14
by Sandro_spb
Great idea! I'll try it! Thank you very much!