Timer using loop or Settimer Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Stinkfoot9
Posts: 51
Joined: 29 May 2022, 12:17

Timer using loop or Settimer

Post by Stinkfoot9 » 09 Dec 2022, 04:08

I'm trying to create a timer that i can edit while the timer is running and Im having trouble.




My Attempt using Loop inside the loop..
Works BUT The problem here is i can't interrupt the loop in order to edit the timer while it's running.

Code: Select all

Gui,add,edit,vx8
Gui, Add, Text,, Set Timer
Gui, Add, Button, w60, Set-t
Gui, Add, Edit, x+n w50 
Gui, Add, UpDown, vtime Range1-90, 60
gui,show
return

Buttonset-t:
{
	Gui, Submit,nohide	
	Time1 := time
	Loop,%Time1%
		{	
		Time1 := (time1 - 1)
		Time2 = 60 
		Loop, 60                                                                              
			{
			time2 := (Time2 - 1)
			Guicontrol, text,x8,%time1% : %time2%
			sleep 100
			}
		}
	}

My attempt with Settimer..
Dosent Work The problem I'm running into here is i need the timer to stop at 0 but it instead goes into negative numbers.
I tried using "settimer,z1, off" but that didn't seem to work as it won't turn back on.

Code: Select all

Gui,add,edit,vx8
Gui, Add, Text,, Set Timer
Gui, Add, Button, w60, Set-t
Gui, Add, Edit, x+n w50 
Gui, Add, UpDown, vtime Range1-90, 60
gui,show
return

Buttonset-t:
{
	Gui, Submit,nohide	
	Time1 := time
	Loop,%Time1%
		{	
		Time1 := (time1 - 1)
		Time2 = 60 
		Settimer, z1, on
			z1:                                                                               
				{
				time2 := (Time2 - 1)
				Guicontrol, text,x8,%time1% : %time2%
				If (time2 = 0)
					{
					Settimer, z1,off
					}
				}
		return				
		}
	}

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Timer using loop or Settimer  Topic is solved

Post by Rohwedder » 09 Dec 2022, 04:33

Hallo.
try:

Code: Select all

Gui,add,edit,vx8
Gui, Add, Text,, Set Timer
Gui, Add, Button, w60, Set-t
Gui, Add, Edit, x+n w50
Gui, Add, UpDown, vtime Range1-90, 60
gui,submit,nohide
gui,show
return
Buttonset-t:
	Gui, Submit,nohide
	Time1 := time, Time2 := 60
	SetTimer, Timer, 100
Return
Timer:
--Time2
IF Time2 < 0
	--Time1, Time2 := 60
IF Time1 < 0
{
	SetTimer, Timer, Off
	Return
}
Guicontrol, text,x8,%time1% : %time2%
Return


Post Reply

Return to “Ask for Help (v1)”