Ammend Count Sleep code to count run time code

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
johnhill
Posts: 24
Joined: 25 Sep 2014, 18:46

Ammend Count Sleep code to count run time code

18 Jul 2015, 01:55

Hi,

Posted under http://www.autohotkey.com/board/topic/1 ... leepcount/.

I have this code that I wanted to used it to count run time of the script. It was used to count Sleep time.

Code: Select all

target_time = 1000
target = %A_YYYY%%A_MM%%A_DD%%target_time%00
EnvSub, target, %A_Now%, Seconds
Sleep, % target * 1000 + 25000 ;  (milliseconds) + delaytime
I played around with it and the best I can get is

Code: Select all

target_time = a_now
Sleep 5123           <--- Added to test the script
target = %A_YYYY%%A_MM%%A_DD%%target_time%00
EnvSub, target, %A_Now%, Seconds
Sleep, % target * 1000 ;  (milliseconds) 
The result I get is around -5300. How to fix the negative into positive number?

Thanks
smokeyTBear2634

Re: Ammend Count Sleep code to count run time code

18 Jul 2015, 02:02

Its not quite slick, but if there is always a negative, you can Just stringtrim...
User avatar
T_Lube
Posts: 67
Joined: 22 Oct 2014, 00:57

Re: Ammend Count Sleep code to count run time code

18 Jul 2015, 02:13

I posted a response on the other forum that may solve it for you, though I don't quite get what you are trying to do exactly.
johnhill
Posts: 24
Joined: 25 Sep 2014, 18:46

Re: Ammend Count Sleep code to count run time code

18 Jul 2015, 06:59

Hi T_Lube,

Is my post not clear?
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Ammend Count Sleep code to count run time code

18 Jul 2015, 07:04

I suggest to measure the time in milliseconds, because you easily can use the built-in variable A_TickCount (see the example).
johnhill
Posts: 24
Joined: 25 Sep 2014, 18:46

Re: Ammend Count Sleep code to count run time code

19 Jul 2015, 03:19

What your suggested is what am I looking for. Thank you.
User avatar
T_Lube
Posts: 67
Joined: 22 Oct 2014, 00:57

Re: Ammend Count Sleep code to count run time code

19 Jul 2015, 03:36

More like I don't totally understand the purpose of it. What I recommend doing is using the function "Abs()" to take your negative value and return it as a positive value. I think that just me has the correct method though, set a variable to value of A_TickCount as start of script then using that var minus it from the new tick count that will give you total amount of ms from start to finish.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: LAPIII, peter_ahk and 327 guests