Convert A_TickCount
Re: Convert A_TickCount
That's great, jeeswg! I like how simple your approach is.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
- Lateralus138
- Posts: 49
- Joined: 30 Aug 2015, 20:52
- Location: Decatur, IL.
- Contact:
Re: Convert A_TickCount
Yes, very nice approach, I am going to turn this into a function for any number and post it here if you don't mind? Honestly, I should've thought of this approach. I read the docs and have seen the Format function before, but I forgot about it. Thanks for your script and inadvertent help with my ideas!jeeswg wrote:Here's an example script:
E.g. for days: you count the number of days (24-hour blocks).
E.g. for hours: you remove the days (any blocks of 24 hours), and count the number of hours.
E.g. for minutes: you remove the hours (any blocks of 60 minutes), and count the number of minutes.
E.g. for seconds: you remove the minutes (any blocks of 60 seconds), and count the number of seconds.Code: Select all
q:: ;tick count to date and friendly format vSec := A_TickCount//1000 vDHMS := Format("{}d {}h {}m {}s", vSec//86400, Mod(vSec,86400)//3600, Mod(vSec,3600)//60, Mod(vSec,60)) vDate := A_Now vDate += -vSec, S ;FormatTime, vDate, % vDate, HH:mm dd/MM/yyyy FormatTime, vDate, % vDate, ddd yyyy-MM-dd HH:mm:ss MsgBox, % "on at: " vDate "`r`n" "on for: " vDHMS return
K̴̡̛̻̮̼͕̬̑̋̀̂͆͛̍̑͢ȩ̮̞͍̩̯̋̈͒͌̕ę̶͓̗͖͔̹̪͗̂̈͛̓͘p̠͉̙̟̒̊͌̐͘͘͟͡͞ S̸͖̖̮̞̥͇̖̓̌͛̽̿̓̊̓̾̚͜w͇̮͓̱͇̘̯͆̓͑̋̇̉͜͝i̢͔̝̳̻̱̋̾͐̾͗͊̀̕͜͡͡n̷̡͔̦̤̝̼̩̎͌̈́̀͛̄͆̎͠ǵ̸̘̝̭̦̠̗͖͌͐͑̑̿̅̈͜͜ḯ̡̬̥̙̩̼̪̑͆̿̌́n̛̼͎̲̬͇̲͉̗̞͊̓̃̂̈͝g̸͕̜͖̪͉͔̩̓̃̀̃͌̑̋̕͘.̪̜̜̜̯̂͂̈́͛̆͗̇̍̇.̟͔͍̙̜̫̗̂̿͛͋͋̈́̾̾̿͑.̡̣̟̝̭͉̦̪́̓̀͛̑̓̐̈͘͘
Re: Convert A_TickCount
Code: Select all
;StrFromTimeInterval function https://msdn.microsoft.com/en-us/library/windows/desktop/bb759980(v=vs.85).aspx
VarSetCapacity(uptime,256,0)
DllCall("Shlwapi.dll\StrFromTimeInterval",str,uptime, UInt,256, UInt,A_TickCount , Int,5)
Msgbox % uptime
Re: Convert A_TickCount
- @Lateralus138: You're welcome to make a function from it, to change as little/as much as you want.
- @iPhilip: Cheers. I remember a long time ago dealing with Excel and the regular use of Mod and Floor divide when dealing with time.
- @noname: Nice, interesting Winapi function.
- Although this was possible from the day Format was created: Format("{}d {}h {}m {}s" and Format("{}x {}y {}w {}h", it took a lot of experimentation with Format and strings before I finally came up with the simple idea. I was looking at string concatenation and eventually realised that you could do {} repeatedly and pass lots of parameters.
- @iPhilip: Cheers. I remember a long time ago dealing with Excel and the regular use of Mod and Floor divide when dealing with time.
- @noname: Nice, interesting Winapi function.
- Although this was possible from the day Format was created: Format("{}d {}h {}m {}s" and Format("{}x {}y {}w {}h", it took a lot of experimentation with Format and strings before I finally came up with the simple idea. I was looking at string concatenation and eventually realised that you could do {} repeatedly and pass lots of parameters.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Convert A_TickCount
That is fine, but I meant you do not need to assign count inside the function, thisThe count is so that you can pass any number
Code: Select all
toHours(count:=False){
Return stuff(count:=count?count:A_TickCount)
}
Code: Select all
toHours(count:=False){
Return stuff(count?count:A_TickCount)
}
Nice one noname
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 93 guests