How to: Shift pressed twice 'send ^c', but avoiding that holding SHIFT will also send ^c Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
cadudesun
Posts: 129
Joined: 04 Jun 2016, 10:26

How to: Shift pressed twice 'send ^c', but avoiding that holding SHIFT will also send ^c

20 Jun 2019, 20:54

Hi,

I'd appreciate help.

I set the script below, which is working properly for CTRL pressed twice 'send ^c'

Code: Select all

~Ctrl::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 400) {
Send ^c
}
Return
However, there is a problem with the script: if I hold SHIFT, it is also sending ^c.

How to improve the script, in order SHIFT pressed twice 'send ^c', but avoiding hold SHIFT sending ^c?

Thank you very much!
Last edited by cadudesun on 23 Jun 2019, 07:55, edited 1 time in total.
Rohwedder
Posts: 7648
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to: CTRL pressed twice 'send ^c', but avoiding that holding SHIFT will also send ^c

21 Jun 2019, 02:39

Hallo,
you want SHIFT pressed twice 'send ^c', but avoiding hold SHIFT sending ^c:

Code: Select all

~Shift Up::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 400)
	Send ^c
Return
cadudesun
Posts: 129
Joined: 04 Jun 2016, 10:26

Re: How to: Shift pressed twice 'send ^c', but avoiding that holding SHIFT will also send ^c

21 Jun 2019, 10:15

Many thanks @Rohwedder !

Changing the trigger shortcut from ~Shift:: to ~Shift Up:: did the job to avoid holding SHIFT sending ^c. Perfect for that!

But I would appreciate further feedback related to another undesirable behavior that came with using ~Shift Up::

I have the Evernote shortcut !#s set to 'copy selection' (snapshot below).
The problem is when I press Evernote's !#s, this shortcut is undesirable triggering the command "shift twice" since the inclusion of 'Up' ~Shift Up::.
To identify the issue, I set the "shift twice" script to run a Msgbox:

Code: Select all

~Shift::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 300) {
Msgbox,test
}
Return
Always I press !#s the Msgbox,test pops-up.
I changed back the shift from ~Shift Up:: to previous ~Shift:: to test again the interference of AHK<>Evernote.
For my surprise, having the regular ~Shift:: without 'up' solved the interference of the AHK script and Evernote shortcut.

Since the AHK script works properly with regular ~Shift::, then I'm correlating the problem of pressing Evernote's !#s triggering the script with the inclusion of 'Up' in ~Shift Up::.

Do you have any idea of how to solve this issue?

Thank you!

--------------------------------
Image
Last edited by cadudesun on 23 Jun 2019, 07:55, edited 1 time in total.
Rohwedder
Posts: 7648
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to: CTRL pressed twice 'send ^c', but avoiding that holding SHIFT will also send ^c

21 Jun 2019, 14:36

perhaps:

Code: Select all

~!#s::TCopy := A_TickCount + 500
~Shift Up::
If (A_PriorHotKey = A_ThisHotKey 
and A_TimeSincePriorHotkey < 400 
and TCopy < A_TickCount)
	Send ^c
Return
cadudesun
Posts: 129
Joined: 04 Jun 2016, 10:26

Re: How to: Shift pressed twice 'send ^c', but avoiding that holding SHIFT will also send ^c

22 Jun 2019, 09:42

Thank you very much @Rohwedder !
Your updated script solved the issue.
Last edited by cadudesun on 23 Jun 2019, 07:55, edited 1 time in total.
cadudesun
Posts: 129
Joined: 04 Jun 2016, 10:26

Re: How to: Shift pressed twice 'send ^c', but avoiding that holding SHIFT will also send ^c

23 Jun 2019, 07:55

Actually, I just realized that if I remap any of the single keys Shift, Alt, Ctrl to be pressed twice to launch a command, when I use many other programs in-built shortcuts they are undesirably triggering those commands under Shift, Alt, Ctrl pressed twice.

So, the issue isn't related just to the initial Evernote interference mentioned previously, and through the workaround bellow became difficult to solve all shortcuts conflicts that are happening:

Code: Select all

~!#s::TCopy := A_TickCount + 500~Shift Up::If (A_PriorHotKey = A_ThisHotKey
and A_TimeSincePriorHotkey < 400
and TCopy < A_TickCount)
Msgbox,TEST
Return
I recorded my screen showing the undesirably interference between applications inbuilt shortcuts (mouse double click on Ditto clipboard manager, and #!s for copying content in Evernote) triggering the AHK command set under Shift, Alt, Ctrl pressed twice. Screencast here: http://bit.ly/2L8iD40

Would there be other workaround to avoid interference, 'protecting' AHK Shift, Alt, Ctrl pressed twice of being triggered when using other in-built applications shortcuts (e.g. Evernote and Ditto)?

Thank you very much!
Rohwedder
Posts: 7648
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to: Shift pressed twice 'send ^c', but avoiding that holding SHIFT will also send ^c

23 Jun 2019, 09:26

Hallo,
your mp4 caused bluescreen here!
I use modifier keys, mouse buttons and wheel only in combination with other keys as hotkeys.
Brings really more problems than benefits!
Maybe this structure will help?:

Code: Select all

;all inbuilt shortcuts with conflicts
~!#s::
~!c::
~^#b::
	TBlock := A_TickCount + 400
Return
#IF TBlock < A_TickCount
~Shift Up::
~Ctrl Up::
~Alt Up::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 400)
	ToolTip,% A_ThisHotKey
Return
#I
cadudesun
Posts: 129
Joined: 04 Jun 2016, 10:26

Re: How to: Shift pressed twice 'send ^c', but avoiding that holding SHIFT will also send ^c

24 Jun 2019, 14:43

Hi @Rohwedder ,
Rohwedder wrote:
23 Jun 2019, 09:26
your mp4 caused bluescreen here!
Sorry indeed! Double checking here if there is any issue with the outputs of my screen recording app (Sharex).
Rohwedder wrote:
23 Jun 2019, 09:26
Maybe this structure will help?:

Code: Select all

;all inbuilt shortcuts with conflicts
~!#s::
~!c::
~^#b::
	TBlock := A_TickCount + 400
Return
#IF TBlock < A_TickCount
~Shift Up::
~Ctrl Up::
~Alt Up::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 400)
	ToolTip,% A_ThisHotKey
Return
#I
Thank you very much for sharing another script, and keeping the conversation!
Through this script I could handle better the shortcuts interference issue.
=>Could you please just confirm if I am using the script the right way?
I inserted your script before everything, then I inserted individual scripts for each remap of the modifiers pressed twice:

Code: Select all

;SCRIPT to avoid shortcuts conflicts
;all inbuilt shortcuts with conflicts
~!#s::
~!c::
~^#b::
	TBlock := A_TickCount + 400
Return
#IF TBlock < A_TickCount
;INDIVIDUAL SCRIPTS for each modifier
;remap Ctrl x2
~Ctrl Up::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 400)
msgbox, test Ctrl x2
Return
;remap Shift x2
~Shift Up::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 400)
msgbox, Shift x2
Return
;remap Alt x2
~Alt Up::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 400)
msgbox, Alt x2
Return
;remap Win x2
~LWin Up::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 400)
msgbox, Win x2
Return
#If
Rohwedder
Posts: 7648
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to: Shift pressed twice 'send ^c', but avoiding that holding SHIFT will also send ^c  Topic is solved

25 Jun 2019, 01:54

Yes, this is how it should work.
I have structured the script a bit more:

Code: Select all

;SCRIPT to avoid shortcuts conflicts
;all inbuilt shortcuts with conflicts
~!#s::
	TBlock := A_TickCount + 500
Return
#IF TBlock < A_TickCount
;INDIVIDUAL SCRIPTS for each modifier
;remap Ctrl x2
~Ctrl Up::
Once_Back()
msgbox, test Ctrl x2
Return
;remap Shift x2
~Shift Up::
Once_Back()
msgbox, Shift x2
Return
;remap Alt x2
~Alt Up::
Once_Back()
msgbox, Alt x2
Return
;remap Win x2
~LWin Up::
Once_Back()
msgbox, Win x2
Return
#If
Once_Back()
{ ;makes an Exit at the first keystroke
	IF (A_PriorHotKey <> A_ThisHotKey Or A_TimeSincePriorHotkey > 400)
		Exit
}
The two Times:
TBlock: 500 ms and keystroke: 400 ms
still need to be optimized!
cadudesun
Posts: 129
Joined: 04 Jun 2016, 10:26

Re: How to: Shift pressed twice 'send ^c', but avoiding that holding SHIFT will also send ^c

25 Jun 2019, 16:09

Rohwedder wrote:
25 Jun 2019, 01:54
Yes, this is how it should work.
I have structured the script a bit more
Thank you very much @Rohwedder.
Your help and attention are much appreciated!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: metallizer and 126 guests