Double tap toggle Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
racer
Posts: 29
Joined: 07 May 2022, 15:02

Double tap toggle

Post by racer » 22 May 2022, 17:21

Hello,
Im trying to make a suspend hotkey. When I press Lbutton twise the script should suspend hotkeys and when I press it again twise, the script should unsuspend hotkeys? Could you please help me? The code below doesn't work for me.

Code: Select all

~LButton::
If (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 200)
Suspend, Toggle
return

User avatar
mikeyww
Posts: 27049
Joined: 09 Sep 2014, 18:38

Re: Double tap toggle  Topic is solved

Post by mikeyww » 22 May 2022, 17:33

Your hotkey stops working when you suspend your script, right? That is the nature of Suspend!

You can permit your hotkey to keep working.

Code: Select all

~LButton::
Suspend, Permit
If (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 200)
 Suspend
Return
Explained: Suspend
Any hotkey/hotstring subroutine whose very first line is Suspend (except Suspend On) will be exempt from suspension. In other words, the hotkey will remain enabled even while suspension is ON. This allows suspension to be turned off via such a hotkey.

racer
Posts: 29
Joined: 07 May 2022, 15:02

Re: Double tap toggle

Post by racer » 22 May 2022, 18:10

mikeyww wrote:
22 May 2022, 17:33
Your hotkey stops working when you suspend your script, right? That is the nature of Suspend!

You can permit your hotkey to keep working.

Code: Select all

~LButton::
Suspend, Permit
If (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 200)
 Suspend
Return
Explained: Suspend
Any hotkey/hotstring subroutine whose very first line is Suspend (except Suspend On) will be exempt from suspension. In other words, the hotkey will remain enabled even while suspension is ON. This allows suspension to be turned off via such a hotkey.
Thank you so much mikeyww

racer
Posts: 29
Joined: 07 May 2022, 15:02

Re: Double tap toggle

Post by racer » 22 May 2022, 18:22

mikeyww wrote:
22 May 2022, 17:33
Your hotkey stops working when you suspend your script, right? That is the nature of Suspend!

You can permit your hotkey to keep working.

Code: Select all

~LButton::
Suspend, Permit
If (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 200)
 Suspend
Return
Explained: Suspend
Any hotkey/hotstring subroutine whose very first line is Suspend (except Suspend On) will be exempt from suspension. In other words, the hotkey will remain enabled even while suspension is ON. This allows suspension to be turned off via such a hotkey.
I got an idea to also press Esc, when I click the Lbutton twice again . What's wrong with my code?

Code: Select all

~LButton::
Suspend, Permit
If (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 200)
if (Toggle := !Toggle)
 Suspend
else
Suspend
SendInput {Esc} 
Return

User avatar
mikeyww
Posts: 27049
Joined: 09 Sep 2014, 18:38

Re: Double tap toggle

Post by mikeyww » 22 May 2022, 20:36

Explained: ElseBlockExample
Blocks are one or more statements enclosed in braces.

Post Reply

Return to “Ask for Help (v1)”