Help with Script disable function

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
roblive
Posts: 5
Joined: 22 Mar 2023, 14:54

Help with Script disable function

30 Apr 2024, 02:41

I make a script with a disable function that blocks the trigger button for a certain time until the script is finished.
Is it possible to interrupt the disabler for e.g. 1500 to press the trigger button multiple times to trigger another specific button before the disabler becomes active and plays the rest of the script?

Code: Select all

F5::	
;-----------------------------
if disabler
	return
else
	disabler := true
	SetTimer, cooldown, -6500
;-----------------------------
Send, {4 down}
Sleep, 100
Send, {4 up}
Sleep, 1000
;-----------------------------
BlockInput, MouseMove
	Sleep, 100
	Send, {E down}
	Sleep, 100
	MouseMove, 830, 500
	Sleep, 100
	Send, {E up}
BlockInput, MouseMoveOff
Sleep, 100
;-----------------------------
Send, {RButton down}
Sleep, 100
Send, {RButton up}
Sleep, 5500
;-----------------------------
Send, {1 down}
Sleep, 100
Send, {1 up}
return
;-----------------------------
cooldown:
	disabler := false
return
I want to be able to press F5 repeatedly to send, {4 down} {4 up} and the script starts over, wait short, otherwise the disabler becomes active.
User avatar
mikeyww
Posts: 27146
Joined: 09 Sep 2014, 18:38

Re: Help with Script disable function

02 May 2024, 08:26

Hello,

You have various options.
  1. Move the cooldown to a later point in the subroutine.
  2. Use a different hotkey that will interrupt this subroutine.
  3. Change your tracking variable.
  4. Add a new tracking variable for the interruptibility.
  5. Use #If to set a context for the hotkey, such that something different will happen if the context is not met.
  6. Use the same hotkey to interrupt this subroutine.
  7. Use a combination of these approaches.
If you want to use the same hotkey with the same context to interrupt itself, you would need to increase the maximum number of threads per hotkey from the default of 1.

Code: Select all

#Requires AutoHotkey v1.1.33.11
#MaxThreadsPerHotkey 2

F5::
If !running {
 running := True
 Loop 25 {
  Send % A_Index " "
  Sleep 90
 }
 running := False
} Else Send abcdefg
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 118 guests