What am I doing WRONG? AUTO STOPWATCH Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
HazelnutMango
Posts: 8
Joined: 01 Aug 2019, 17:14

What am I doing WRONG? AUTO STOPWATCH

02 Aug 2019, 02:37

Thanks for taking the time to read my post!

I hope you can help me. I wanted to have an auto timer/stopwatch that uses if to "show a message" or to do a command.

I wanted to incorporate it to my code but I can't get through this part.

Here's the code:

Code: Select all

F1::

StartTime := A_TickCount

ElapsedTime := A_TickCount - StartTime

	if (ElapsedTime := 5000)
		MsgBox,  %ElapsedTime% milliseconds have elapsed.
	
return
trust_me
Posts: 83
Joined: 29 Jul 2017, 10:46

Re: What am I doing WRONG? AUTO STOPWATCH

02 Aug 2019, 06:44

There is no loop , it will execute only once without redoing it until 5000 has elapsed.

Code: Select all

F1::
StartTime := A_TickCount
loop 
ElapsedTime :=A_TickCount - StartTime
until ElapsedTime=5000

MsgBox  %ElapsedTime% milliseconds have elapsed.
	
return
User avatar
boiler
Posts: 5278
Joined: 21 Dec 2014, 02:44

Re: What am I doing WRONG? AUTO STOPWATCH  Topic is solved

02 Aug 2019, 06:49

You should use >= instead of = because many milliseconds pass between each loop, so you'd be lucky if you happen to catch it when it reaches exactly 5000.
HazelnutMango
Posts: 8
Joined: 01 Aug 2019, 17:14

Re: What am I doing WRONG? AUTO STOPWATCH

02 Aug 2019, 06:55

Thanks for all the help!!

This worked:

Code: Select all

F1::
StartTime := A_TickCount
loop 
ElapsedTime :=A_TickCount - StartTime
until ElapsedTime>=5000

MsgBox  %ElapsedTime% milliseconds have elapsed.
	
return

Return to “Ask For Help”

Who is online

Users browsing this forum: Clemens375 and 221 guests