Loop (and create a countdown) on a var created from args

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
partof
Posts: 110
Joined: 16 Jan 2016, 08:38

Loop (and create a countdown) on a var created from args

13 Jan 2019, 14:48

I am starting my ahk script from a python scrip with an argument "number" (which is an integer but set as a string variable):

Code: Select all

subprocess.call([path_ahk_exe, path_ahk_script_countdown, number])
Then in the ahk script I need to create a Tooltip that countdown from the time set in the args. If Number is set to 15 I should then see 15, 14,... 3,2,1...
But I don't see this, I literally see "15 - A_Index"
Any idea how to solve this? Thanks for your help!

Here is my script:

Code: Select all

Number := %0% , Number += 0  ; convert text to number

Loop %Number%       
	{
		 ToolTip, %  %Number% - A_Index ; if you just use A_Index it starts at 1 2 3 etc
		 Sleep 1000
		}
Tooltip, 0
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Loop (and create a countdown) on a var created from args

13 Jan 2019, 15:23

its because ure double-derefing Number, also why do it in this archaic way:

Code: Select all

Loop % A_Args[1]
{
	ToolTip % --A_Args[1]
	Sleep 1000
}
ToolTip
partof
Posts: 110
Joined: 16 Jan 2016, 08:38

Re: Loop (and create a countdown) on a var created from args

17 Jan 2019, 14:24

Sorry for the delay and thanks so much as it's working great!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: kashmirLZ and 215 guests