Comman Continue Starts the Loop Over Autohotkey

JellyBelly

  • Guests
  • Last active:
  • Joined: --

how do you set a hotkey to reset the same script or to break a loop

what i have will start a loop sequence but i need to to be able to stoped with either another hotkey or the same hotkey to end it. and then be able to restart it at a later time.

^x:: loop { send, 2 sleep 9000 send, 3 sleep 5000 }  return ^c:: exitapp            

can anyone give me some pointers or a topic to try to search for on this issue?

  • Back to top

  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007

Read the FAQ :!: It is a good place to start:
<!-- m -->http://www.autohotke.../FAQ.htm#repeat<!-- m -->

  • Back to top

  • Guests
  • Last active:
  • Joined: --

how do you set a hotkey to reset the same script or to break a loop

what i have will start a loop sequence but i need to to be able to stoped with either another hotkey or the same hotkey to end it. and then be able to restart it at a later time.

^x:: loop { send, 2 sleep 9000 send, 3 sleep 5000 }  return ^c:: exitapp              

can anyone give me some pointers or a topic to try to search for on this issue?
^x:: continue := true loop { send, 2 sleep 9000 send, 3 sleep 5000 if continue = false 	break }  return  ^b:: continue := false ^c:: exitapp

maybe something like this?

  • Back to top

JellyBelly

  • Guests
  • Last active:
  • Joined: --
^x:: continue := true 	loop { WinGet, thirstid, List,  Thirst 		IfWinActive, Thirst 	ControlSend,, {4}, ahk_id %thirstid2% Sleep 10 	ControlSend,, {5}, ahk_id %thirstid2% Sleep 10 	ControlSend,, {3}, ahk_id %thirstid2% Sleep 10                 if continue = false     		break   	} return ^c:: continue := false

is my current exact script
ctrl + x starts but ctrl + c doesnt break the script

there are 2 instances of a program i use called thirst open and the one i do not have active i want it to send the script to it does but i need a way to break the script and i cant seem to figure this out

and pause did not work either

^x::  	loop { WinGet, thirstid, List,  Thirst 		IfWinActive, Thirst 	ControlSend,, {4}, ahk_id %thirstid2% Sleep 10 	ControlSend,, {5}, ahk_id %thirstid2% Sleep 10 	ControlSend,, {3}, ahk_id %thirstid2% Sleep 10                  	} return ^c::pause

the loop never gets broken

ive tride placeing it with in the loop but it just runs it once that way.

  • Back to top

JellyBelly

  • Guests
  • Last active:
  • Joined: --
#MaxThreadsPerHotkey 3 #z::  #MaxThreadsPerHotkey 1  if KeepWinZRunning   {     KeepWinZRunning := false       return   } KeepWinZRunning := true   	loop { WinGet, thirstid, List,  thirst 		IfWinActive, thirst 	ControlSend,, {4}, ahk_id %thirstid2% Sleep 10 	ControlSend,, {5}, ahk_id %thirstid2% Sleep 10 	ControlSend,, {3}, ahk_id %thirstid2%  Sleep 10     if not KeepWinZRunning           break 	 	} KeepWinZRunning := false   return

isnt working the way i thought it should either

it starts but wont break

  • Back to top

  • Guests
  • Last active:
  • Joined: --
#MaxThreadsPerHotkey 3    KeepWinZRunning := true    #z::       loop {  WinGet, thirstid, List,  thirst        IfWinActive, thirst     ControlSend,, {4}, ahk_id %thirstid2%  Sleep 10     ControlSend,, {5}, ahk_id %thirstid2%  Sleep 10     ControlSend,, {3}, ahk_id %thirstid2%    if KeepWinZRunning = false  	break       }    Esc::  KeepWinZRunning := false   return

  • Back to top

JellyBelly

  • Guests
  • Last active:
  • Joined: --

still wont break and i copied exactly what you posted

  • Back to top

  • Guests
  • Last active:
  • Joined: --

and you're pressing Esc to break the loop?

  • Back to top

JellyBelly

  • Guests
  • Last active:
  • Joined: --

yes

  • Back to top

engunneer

  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005

you might want to start a new file, just to be sure you are running the one you think you are running.

also, pepper your code with msgbox to see if the esc hotkey is running, or use tooltip to keep updating so you can see a variable while the script is running.

  • Back to top

xdaxdb

  • Members
  • 7 posts
  • Last active: Jul 10 2014 04:09 PM
  • Joined: 24 Jul 2012

$F1:: ; Make the F1 key into a hotkey (the $ symbol facilitates the "P" mode of GetKeyState below).
Loop ; Since no number is specified with it, this is an infinite loop unless "break" or "return" is encountered inside.
{
if not GetKeyState("F1", "P") ; If this statement is true, the user has physically released the F1 key.
break ; Break out of the loop.
; Otherwise (since the above didn't "break"), keep clicking the mouse.
Click ; Click the left mouse button at the cursor's current position.
}
return


  • Back to top

nottfroact1945.blogspot.com

Source: https://www.autohotkey.com/board/topic/41264-hotkey-to-break-a-loop/

0 Response to "Comman Continue Starts the Loop Over Autohotkey"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel