Rawox Posted May 16, 2010 Author Posted May 16, 2010 I'm able to run it, this is what it returns (in dutch) Statistieken vanaf 16-5-2010 22:28:17 Geaccepteerde sessies 1 Sessies geannuleerd door tijdsoverschrijding 0 Sessies geannuleerd vanwege fout 0 Verzonden kilobytes 0 Ontvangen kilobytes 0 Gemiddelde reactietijd (msec) 0 Systeemfouten 0 Schendingen van toegangsrechten 0 Wachtwoordschendingen 0 Gebruikte bestanden 0 Gebruikte communicatieapparaten 0 In wachtrij geplaatste afdruktaken 0 Aantal keren buffers uitgeput Grote buffers 0 Aanvragen buffers 0 De opdracht is voltooid.
GEOSoft Posted May 17, 2010 Posted May 17, 2010 (edited) Just as I suspected. A language issue. Use any of the above code and change "Statistics since" to "Statistieken vanaf" or better yet use Regular Expression to get the date and time.#include <Constants.au3> $out = Run("net stats srv","",@SW_hide,$STDOUT_CHILD) local $output While 1 $output &= StdoutRead($out) If @error Then ExitLoop Wend $start = StringRegExpReplace($output, ".*(?m:^|\n)(?s)[\w\s]+(\d.+:\d+).*", "$1")) MsgBox(0, "result", $start)After a slight nudge in the right direction (read as a boot in the arse) I found this one for you too. If you use it make sure to credit SmOke_N.http://www.autoitscript.com/forum/index.php?showtopic=40321&view=findpost&p=300119Edit #60037:And yet another one from SmOke_N that does everything and is even more accurate (28 seconds better in testing)#include <date.au3> $sLast = _LastRestart() MsgBox(0, "Result", $sLast) Func _LastRestart() Local $i_now_time = _NowCalc() Local $iSubTotal = DllCall('kernel32.dll', 'int', 'GetTickCount') If Not IsArray($iSubTotal) Then Return SetError(1, 0, 0) $iSubTotal = $iSubTotal[0] / 1000 Local $iWeek = Int(($iSubTotal / 604800)) If $iWeek > 0 Then $iSubTotal -= $iWeek * 604800 Local $iDay = Int(($iSubTotal / 86400)) If $iDay > 0 Then $iSubTotal -= $iDay * 86400 Local $iHour = Int(($iSubTotal / 3600)) Local $iMin = Int(($iSubTotal - ($iHour * 3600)) / 60) Local $iSec = Int(($iSubTotal - $iHour * 3600) - ($iMin * 60)) Local $s_date_convert = $i_now_time If $iWeek Then $s_date_convert = _DateAdd("w", -$iWeek, $s_date_convert) If $iDay Then $s_date_convert = _DateAdd("d", -$iDay, $s_date_convert) If $iHour Then $s_date_convert = _DateAdd("h", -$iHour, $s_date_convert) If $iMin Then $s_date_convert = _DateAdd("n", -$iMin, $s_date_convert) If $iSec Then $s_date_convert = _DateAdd("s", -$iSec, $s_date_convert) Return $s_date_convert EndFuncAll the credit goes to the man (SmOke_N). Edited May 17, 2010 by GEOSoft George Reveal hidden contents Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
hawky358 Posted May 17, 2010 Posted May 17, 2010 On 5/17/2010 at 2:27 AM, 'GEOSoft said: Edit #60037: And yet another one from SmOke_N that does everything and is even more accurate (28 seconds better in testing) #include <date.au3> $sLast = _LastRestart() MsgBox(0, "Result", $sLast) Func _LastRestart() Local $i_now_time = _NowCalc() Local $iSubTotal = DllCall('kernel32.dll', 'int', 'GetTickCount') If Not IsArray($iSubTotal) Then Return SetError(1, 0, 0) $iSubTotal = $iSubTotal[0] / 1000 Local $iWeek = Int(($iSubTotal / 604800)) If $iWeek > 0 Then $iSubTotal -= $iWeek * 604800 Local $iDay = Int(($iSubTotal / 86400)) If $iDay > 0 Then $iSubTotal -= $iDay * 86400 Local $iHour = Int(($iSubTotal / 3600)) Local $iMin = Int(($iSubTotal - ($iHour * 3600)) / 60) Local $iSec = Int(($iSubTotal - $iHour * 3600) - ($iMin * 60)) Local $s_date_convert = $i_now_time If $iWeek Then $s_date_convert = _DateAdd("w", -$iWeek, $s_date_convert) If $iDay Then $s_date_convert = _DateAdd("d", -$iDay, $s_date_convert) If $iHour Then $s_date_convert = _DateAdd("h", -$iHour, $s_date_convert) If $iMin Then $s_date_convert = _DateAdd("n", -$iMin, $s_date_convert) If $iSec Then $s_date_convert = _DateAdd("s", -$iSec, $s_date_convert) Return $s_date_convert EndFunc All the credit goes to the man (SmOke_N). Cool. This is probably more robust as well. The net stats shows the time when the net service started, so if for some reason it's restarted or doesn't run it will show incorrectly. Thanks GEOSoft / SmOke_N
Rawox Posted May 17, 2010 Author Posted May 17, 2010 Yay, think this will work! Thanks for all the help, both GEOSoft and SmOke_N
GEOSoft Posted May 17, 2010 Posted May 17, 2010 happy to be of assistance and happier still that SmOke_N did all the work. BTW, if you follow that link I gave you and look at the last post, he added a new version of the above code. George Reveal hidden contents Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
GEOSoft Posted May 17, 2010 Posted May 17, 2010 personally I would have that new function return an array where element[0] is the formatted date and element[1] is the time, but if I mention that to him all he's going to do is accuse me of nit picking and I can't have that. George Reveal hidden contents Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Rawox Posted May 17, 2010 Author Posted May 17, 2010 Haha, let's keep it our secret then, and the people that read this topic -.-'
trancexx Posted May 17, 2010 Posted May 17, 2010 On 5/17/2010 at 2:27 AM, 'GEOSoft said: After a slight nudge in the right direction (read as a boot in the arse) I found this one for you too. If you use it make sure to credit SmOke_N. #300119 Edit #60037: And yet another one from SmOke_N that does everything and is even more accurate (28 seconds better in testing) #include <date.au3> $sLast = _LastRestart() MsgBox(0, "Result", $sLast) Func _LastRestart() Local $i_now_time = _NowCalc() Local $iSubTotal = DllCall('kernel32.dll', 'int', 'GetTickCount') If Not IsArray($iSubTotal) Then Return SetError(1, 0, 0) $iSubTotal = $iSubTotal[0] / 1000 Local $iWeek = Int(($iSubTotal / 604800)) If $iWeek > 0 Then $iSubTotal -= $iWeek * 604800 Local $iDay = Int(($iSubTotal / 86400)) If $iDay > 0 Then $iSubTotal -= $iDay * 86400 Local $iHour = Int(($iSubTotal / 3600)) Local $iMin = Int(($iSubTotal - ($iHour * 3600)) / 60) Local $iSec = Int(($iSubTotal - $iHour * 3600) - ($iMin * 60)) Local $s_date_convert = $i_now_time If $iWeek Then $s_date_convert = _DateAdd("w", -$iWeek, $s_date_convert) If $iDay Then $s_date_convert = _DateAdd("d", -$iDay, $s_date_convert) If $iHour Then $s_date_convert = _DateAdd("h", -$iHour, $s_date_convert) If $iMin Then $s_date_convert = _DateAdd("n", -$iMin, $s_date_convert) If $iSec Then $s_date_convert = _DateAdd("s", -$iSec, $s_date_convert) Return $s_date_convert EndFunc All the credit goes to the man (SmOke_N). Unnecessarily complicated. That function could be written in not more than three little lines. Scary. ♡♡♡ . eMyvnE
GEOSoft Posted May 17, 2010 Posted May 17, 2010 On 5/17/2010 at 11:17 PM, 'trancexx said: Unnecessarily complicated. That function could be written in not more than three little lines.Scary.Nothing to stop you from rewriting it. George Reveal hidden contents Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Moderators SmOke_N Posted May 18, 2010 Moderators Posted May 18, 2010 (edited) On 5/17/2010 at 11:17 PM, 'trancexx said: Unnecessarily complicated. That function could be written in not more than three little lines. Scary. Since you've posted one of your "As useful as tits on a flea" comments ... I imagine you're referring to something like#include <date.au3> MsgBox(64, "Info", _LastRestart()) Func _LastRestart() Local $a_ms = DllCall('kernel32.dll', 'int', 'GetTickCount') Return _DateAdd("s", -Int($a_ms[0] / 1000), _NowCalc()) EndFunc Edit: Wait, that's 4 lines of code if you count the Func/EndFunc ... hmmm Edited May 18, 2010 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
GEOSoft Posted May 18, 2010 Posted May 18, 2010 On 5/18/2010 at 12:00 AM, 'SmOke_N said: Since you've posted one of your "As useful as tits on a flea" comments ... I imagine you're referring to something likeEdit:Wait, that's 4 lines of code if you count the Func/EndFunc ... hmmmSorry, it has to be in 3 and don't forget that it has to return the date and time. preferably for the proper locale and it should allow for 12 and 24 hour returns. George Reveal hidden contents Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
GEOSoft Posted May 18, 2010 Posted May 18, 2010 Hmmmm, this is not what I expected. I would have thought writing 3 lines of code would take much less time than writing a complex function, but I guess that just doesn't apply when you're dealing with pro's. George Reveal hidden contents Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
trancexx Posted May 18, 2010 Posted May 18, 2010 On 5/18/2010 at 12:00 AM, 'SmOke_N said: Since you've posted one of your "As useful as tits on a flea" comments ... I imagine you're referring to something like#include <date.au3> MsgBox(64, "Info", _LastRestart()) Func _LastRestart() Local $a_ms = DllCall('kernel32.dll', 'int', 'GetTickCount') Return _DateAdd("s", -Int($a_ms[0] / 1000), _NowCalc()) EndFunc Edit: Wait, that's 4 lines of code if you count the Func/EndFunc ... hmmm Your imagination was good. Func/EndFunc is never counted and third line would be error checking. (Fourth GetTickCount64 maybe) @GEOSoft, if I knew in advance you would be that affected I wouldn't post, that's for sure. ♡♡♡ . eMyvnE
hawky358 Posted May 18, 2010 Posted May 18, 2010 Hey If anyone is interested there's a autoit function which returns this: DllCall('kernel32.dll', 'int', 'GetTickCount') _Date_Time_GetTickCount()
DW1 Posted May 18, 2010 Posted May 18, 2010 Nice. So there you have it. Three lines afterall <poke's the bear> #include <date.au3> MsgBox(64, "Info", _LastRestart()) Func _LastRestart() Return _DateAdd("s", -Int(_Date_Time_GetTickCount() / 1000), _NowCalc()) EndFunc AutoIt3 Online Help
firsttimer Posted April 25, 2014 Posted April 25, 2014 On 5/18/2010 at 8:40 AM, DW1 said: Nice. So there you have it. Three lines afterall <poke's the bear> #include <date.au3> MsgBox(64, "Info", _LastRestart()) Func _LastRestart() Return _DateAdd("s", -Int(_Date_Time_GetTickCount() / 1000), _NowCalc()) EndFunc This code works great but I encountered one problem. After I tested countless times running in scite or compiled exe file. I get 2 results its either 2014/04/26 01:14:07 or 2014/04/26 01:14:08 Anybody know why?
BrewManNH Posted April 25, 2014 Posted April 25, 2014 It's probably due to rounding issues. It's one second difference, is that such a deal breaker that you resurrected a 4 year old thread? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! Reveal hidden contents I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
firsttimer Posted April 26, 2014 Posted April 26, 2014 (edited) On 4/25/2014 at 8:36 PM, BrewManNH said: It's probably due to rounding issues. It's one second difference, is that such a deal breaker that you resurrected a 4 year old thread? Yes, I need it to be accurate. I compare the check time against a previous check time for relogin. Any solution/workaround for it? Or a better method to check relogin? Edited April 26, 2014 by firsttimer
BrewManNH Posted April 26, 2014 Posted April 26, 2014 That script has nothing to do with log in time,it's reading last restart time. And I repeat, is a one second difference going to make a bit of a difference in the script? So what if it was booted up 10 seconds ago or 11 seconds ago? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! Reveal hidden contents I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now