Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

How do you stop subroutines under SetTimer?



  • Please log in to reply
5 replies to this topic
Namyag
  • Members
  • 3 posts
  • Last active: Aug 05 2013 10:41 AM
  • Joined: 05 Aug 2013
How do you stop subroutines under SetTimer?
 
Hello, AHK members.  I have a simple problem.  How do I get the subroutines under SetTimer to stop?
 
I play Ragnarok Online and I have made this block of code to refresh the timers of buff skills periodically:
 
SetTimer, attentionConcentrate, 5000
SetTimer, trueSight, 7000
SetTimer, windWalk, 9000


attentionConcentrate:
Send {F5}

trueSight:
Send q

windWalk:
Send w

return
My problem now is that short of turning off the script manually, I don't know how to terminate the loop created by SetTimer.  Is there any way to get out of the loop?


Menixator
  • Members
  • 744 posts
  • Last active: Sep 01 2015 02:54 PM
  • Joined: 10 Jul 2013

Yes. There is.

SetTimer,LabelName,Off

Will do the job.



Namyag
  • Members
  • 3 posts
  • Last active: Aug 05 2013 10:41 AM
  • Joined: 05 Aug 2013

How, exactly, does

SetTimer,LabelName,Off

work?

 

What I want to happen is I want the script to continue looping until such time that I enter a command to get out of the loop.



Menixator
  • Members
  • 744 posts
  • Last active: Sep 01 2015 02:54 PM
  • Joined: 10 Jul 2013
✓  Best Answer

You use the label name that was used to start the timer followed by a comma and an "off":

Examine the code below. It starts all the timers and stops them all if Winkey+P is pressed.


SetTimer, attentionConcentrate, 5000
SetTimer, trueSight, 7000
SetTimer, windWalk, 9000
return

#p::
SetTimer, attentionConcentrate, off
SetTimer, trueSight, off
SetTimer, windWalk, off
return


attentionConcentrate:
Send {F5}
return

trueSight:
Send q
return

windWalk:
Send w
return


Namyag
  • Members
  • 3 posts
  • Last active: Aug 05 2013 10:41 AM
  • Joined: 05 Aug 2013

All right!  Thanks!



AhkLearner
  • Members
  • 101 posts
  • Last active: Aug 27 2016 12:58 PM
  • Joined: 25 Feb 2014

 

You use the label name that was used to start the timer followed by a comma and an "off":

Examine the code below. It starts all the timers and stops them all if Winkey+P is pressed.


SetTimer, attentionConcentrate, 5000
SetTimer, trueSight, 7000
SetTimer, windWalk, 9000
return

#p::
SetTimer, attentionConcentrate, off
SetTimer, trueSight, off
SetTimer, windWalk, off
return


attentionConcentrate:
Send {F5}
return

trueSight:
Send q
return

windWalk:
Send w
return

 

Truly Great