thank you all for help
@MonuKashyap , this is your script below ( just used CODE for better readable and little modified as example for me to keep it ) , the variable 'count' was empty , can use if wanted ( here it's same as a_index )
added guicontrol for Edit
as title = How to start and break a loop with ONE button
Code: Select all
;-- https://autohotkey.com/boards/viewtopic.php?f=5&t=43986
;-- test start / stop break a loopX & GUI example
;- example GUI,2: / not needed to write '2:' if define first as 'NEW'
;- GUI,2: New,, Example ;- only write once '2:'
#warn
Setworkingdir,%a_scriptdir%
count:=0
Gui,2: default
gui,2: font, s20
gui,2: add, edit , vED1 right cGray
gui,2: add, button, x10 y110 w100 gStart vStartButton Default, Start
gui,2: add, button, x10 y110 w100 gStop vStopButton Default, Stop
gui,2: add, button, x150 y110 w160 gCalc center,Calculator
Guicontrol,2: hide , StopButton
Guicontrol,2: disable, StopButton
gui,2: show,,Loop_Test
return
calc:
run,calc
return
Stop:
Stop:=1
Guicontrol,2: hide , StopButton
Guicontrol,2: disable, StopButton
Guicontrol,2: Show , Startbutton
Guicontrol,2: Enable , Startbutton
tooltip
Return
Start:
Guicontrol,2: hide , Startbutton
Guicontrol,2: disable, Startbutton
Guicontrol,2: Show , StopButton
Guicontrol,2: Enable , StopButton
Stop:=0
loop
{
; do something until STOP
count++
Guicontrol,2:,ed1,%count%
tooltip, % "A_Index=" . a_Index . "`nCount=" . count
if Stop
Break
}
msgbox, 262208,STOP ,Loop stopped`nYou can start again ( if wanted ),3
Return
esc::
2guiclose:
exitapp