WhOOt Posted February 2, 2007 Share Posted February 2, 2007 Hey again guys I was making this program, so that I could how long time I spent at my computer.. It's not something big, just a little thing to keep up my programming I was thinking if someone could correct some of my bads? And also my very unorganized programming is bad for the script.. Thanks for anyone, who is willing to help And to everyone, who took his time to read the topic Thanks WhOOt ::BTW, I did not write all of this, I borrowed some of the code from others from the site Autoit_Example_scripts.rar Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 2, 2007 Moderators Share Posted February 2, 2007 Ha, I didn't think anyone would actually use that function. 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. Link to comment Share on other sites More sharing options...
evilertoaster Posted February 2, 2007 Share Posted February 2, 2007 @command prompt- systeminfo | find "System Up Time:" Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 2, 2007 Moderators Share Posted February 2, 2007 @command prompt- systeminfo | find "System Up Time:"Mines much faster expandcollapse popup#include <array.au3> $nTimer1 = TimerInit() $aArray1 = _TimeSystemRestart() $nDiff1 = TimerDiff($nTimer1) $nTimer2 = TimerInit() $aArray2 = _TimeSystemRestartCMD() $nDiff2 = TimerDiff($nTimer2) ConsoleWrite(@LF & 'Timer 1: ' & $nDiff1 & @LF & @LF & 'Timer 1: ' & $nDiff2 & @LF) _ArrayDisplay($aArray1, 'DLL') _ArrayDisplay($aArray2, 'CMD') Func _TimeSystemRestart() 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)) Return StringSplit(StringFormat('%02d', $iWeek) & ':' & $iDay & ':' & StringFormat('%02d', $iHour) & ':' & _ StringFormat('%02d', $iMin) & ':' & StringFormat('%02d', $iSec), ':') EndFunc Func _TimeSystemRestartCMD() Local $iPID = Run(@ComSpec & ' /c systeminfo | find "System Up Time:"', '', @SW_HIDE, 6) Local $sHold = '' While Not @error $sHold &= StdoutRead($iPID) WEnd If $sHold = '' Then Return SetError(1, 0, '') $sHold = StringStripWS($sHold, 8) $sHold = StringReplace($sHold, 'SystemUpTime:', '') If Not StringInStr($sHold, 'Minutes') Then $sHold = '0Minutes,' & $sHold If Not StringInStr($sHold, 'Hours') Then $sHold = '0Hours,' & $sHold If Not StringInStr($sHold, 'Days') Then $sHold = '0Days,' & $sHold If Not StringInStr($sHold, 'Weeks') Then $sHold = '0Weeks,' & $sHold Local $aArray = StringRegExp($sHold, '(\d+).*?(\d+).*?(\d+).*?(\d+).*?(\d+)', 1) If IsArray($aArray) = 0 Then Return SetError(2, 0, '') Local $aReturn[UBound($aArray) + 1], $iAdd = 0 For $iCC = 0 To UBound($aArray) - 1 $iAdd += 1 If $iCC <> 1 Then $aReturn[$iAdd] &= StringFormat('%02d', $aArray[$iCC]) If $iCC = 1 Then $aReturn[$iAdd] &= $aArray[$iCC] Next Return $aReturn EndFunc 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. Link to comment Share on other sites More sharing options...
dandymcgee Posted February 2, 2007 Share Posted February 2, 2007 Mines much fasterlol... - Dan [Website] Link to comment Share on other sites More sharing options...
WhOOt Posted February 3, 2007 Author Share Posted February 3, 2007 Mines much faster expandcollapse popup#include <array.au3> $nTimer1 = TimerInit() $aArray1 = _TimeSystemRestart() $nDiff1 = TimerDiff($nTimer1) $nTimer2 = TimerInit() $aArray2 = _TimeSystemRestartCMD() $nDiff2 = TimerDiff($nTimer2) ConsoleWrite(@LF & 'Timer 1: ' & $nDiff1 & @LF & @LF & 'Timer 1: ' & $nDiff2 & @LF) _ArrayDisplay($aArray1, 'DLL') _ArrayDisplay($aArray2, 'CMD') Func _TimeSystemRestart() 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)) Return StringSplit(StringFormat('%02d', $iWeek) & ':' & $iDay & ':' & StringFormat('%02d', $iHour) & ':' & _ StringFormat('%02d', $iMin) & ':' & StringFormat('%02d', $iSec), ':') EndFunc Func _TimeSystemRestartCMD() Local $iPID = Run(@ComSpec & ' /c systeminfo | find "System Up Time:"', '', @SW_HIDE, 6) Local $sHold = '' While Not @error $sHold &= StdoutRead($iPID) WEnd If $sHold = '' Then Return SetError(1, 0, '') $sHold = StringStripWS($sHold, 8) $sHold = StringReplace($sHold, 'SystemUpTime:', '') If Not StringInStr($sHold, 'Minutes') Then $sHold = '0Minutes,' & $sHold If Not StringInStr($sHold, 'Hours') Then $sHold = '0Hours,' & $sHold If Not StringInStr($sHold, 'Days') Then $sHold = '0Days,' & $sHold If Not StringInStr($sHold, 'Weeks') Then $sHold = '0Weeks,' & $sHold Local $aArray = StringRegExp($sHold, '(\d+).*?(\d+).*?(\d+).*?(\d+).*?(\d+)', 1) If IsArray($aArray) = 0 Then Return SetError(2, 0, '') Local $aReturn[UBound($aArray) + 1], $iAdd = 0 For $iCC = 0 To UBound($aArray) - 1 $iAdd += 1 If $iCC <> 1 Then $aReturn[$iAdd] &= StringFormat('%02d', $aArray[$iCC]) If $iCC = 1 Then $aReturn[$iAdd] &= $aArray[$iCC] Next Return $aReturn EndFunc Yea, but what I am looking for, is one that saves your current 'on-time', and adds it to a file or something, and adds then up, so that you can see current on time and All on-'times added up. So that I can see if I've been on my computer for 1 week, in a month Thanks WhOOt Link to comment Share on other sites More sharing options...
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