Resuming and pausing script flexibly

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
CrawfordPNX
Posts: 38
Joined: 03 Dec 2016, 12:44

Resuming and pausing script flexibly

Post by CrawfordPNX » 23 Oct 2021, 22:31

Hello community. I've been using a convenience script for a long time but I thought it's about time I make some necessary changes.
First of all, how can I bind Mouseforward to resuming a script? Perhaps detect IF script is paused, and if so, execute 'pause' to resume?
On top of mouseforward, I'd like a double tap of the D key within one second to turn script back on, and stay on if it's already on.
Most importantly, how would I go on pausing the script if I press any key other than a couple specific keys, e.g A,D,G?
Thank you so much.

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

Re: Resuming and pausing script flexibly

Post by mikeyww » 24 Oct 2021, 05:34

Ideas:

Code: Select all

Loop, 512                   ; Block the keyboard (pause script)
 If A_Index not in 30,32,34 ;  except a, d, g
  Hotkey, % Format("*SC{:X}", A_Index), Pause, On UseErrorLevel

#If A_IsPaused
~d::
~SC3D::
If (A_PriorHotkey ~= "(~d|~SC3D)" && A_TimeSincePriorHotkey < 1000) ; Double-press
 Pause, Off
Return
#If

Pause:
Pause, On, 1
Return

CrawfordPNX
Posts: 38
Joined: 03 Dec 2016, 12:44

Re: Resuming and pausing script flexibly

Post by CrawfordPNX » 24 Oct 2021, 11:58

Hello.
The script doesn't seem to work. For example I'd press 'J' instead of A/D/G after implementing the changes but the script would not pause.
Fyi I already use A and D for ctrl shift tab/ ctrl tab respectively. This might be why the double 'D' tap doesn't work.
Again, I'd like A,D,G,T to be the exceptions. I looked up A_index but nowhere does it show how 30,32,34 correspond to a,d,g. However, I did learn how to break a loop with A_index thanks to that.
Again, thank you for the help.

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

Re: Resuming and pausing script flexibly

Post by mikeyww » 24 Oct 2021, 12:42

Auto-execute section goes at the top. If you already have a script, then post it.

Post Reply

Return to “Ask for Help (v1)”