Running Loop for a Limited Amount of Time Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
gignu
Posts: 30
Joined: 14 Jun 2019, 09:00

Running Loop for a Limited Amount of Time

10 Jul 2019, 16:05

I'm trying to run my loop for two seconds. Within those two seconds, if I click left a message box gets activated, telling me that I've clicked left. If the 2 seconds are up another message box is supposed to appear, telling me that I've been waiting enough. However, after 2 seconds nothing happens ;(

Code: Select all

:*:tcc::
	start := A_TickCount
	totalTime := stop - start
	Loop {
		stop := A_TickCount		
		if (totalTime > 2000)
			{
			MsgBox, enough waiting!
			return
			}	
		else if GetKeyState("LButton")
			{
			MsgBox, you clicked left
			return
			}
	}
User avatar
AlphaBravo
Posts: 586
Joined: 29 Sep 2013, 22:59

Re: Running Loop for a Limited Amount of Time  Topic is solved

10 Jul 2019, 19:31

totalTime := stop - start needs to be inside the loop
gignu
Posts: 30
Joined: 14 Jun 2019, 09:00

Re: Running Loop for a Limited Amount of Time

12 Jul 2019, 07:41

Thank you!! That did the trick ;)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bubo_Bubo and 201 guests