nadigo 0 Posted August 28, 2010 Hi, I wrote a small script that is run in the tray and preform update functions every 6 and 24 hours.The aim was to reduce cpu/memory so I only check the update status every 3 hours.For some reason, the attached script works well for short times (few mins) but will NOT work for the 6-24 hours I need.Since my computer is set to hibernate every 2 hours, the actual testing I made was to run the complied exe, wait that my computer will get into hibernation, wake it up few ours later, and wait for the update to run , nothing happed. What am I missing ?Thanks for the Help, Nadigoexpandcollapse popup#Include <GDIPlus.au3> #Include <Date.au3> #Include <Constants.au3> #include <IE.au3> #NoTrayIcon Opt("TrayMenuMode", 1) Func UpdateStr () ; Do stuff $ini = IniWrite($MyWorkingDir & "\Config.ini", "MyProcess" ,"LastStrUpdate", _NowCalc()) MsgBox (64, "Update", "UpdateStr") return EndFunc;==>ChngBG Func Update () ; Do stuff $ini = IniWrite($MyWorkingDir & "\Config.ini", "MyProcess" ,"LastUpdate", _NowCalc()) MsgBox (64, "Update", "Update") return EndFunc;==>ChngBG ;------------------------------------------------------------------------------- ;############################################################################### Sleep (100) ;Make sure only one script is ruuning $Pno = ProcessList("MyProcess.exe") If $Pno[0][0] > 1 Then Exit Global $iTimer = _NowCalc() $MyWorkingDir = @HomePath $MyProcessItem = TrayCreateItem("MyProcess") TrayCreateItem("") $updateitem = TrayCreateItem("Update Now") $sendafriend = TrayCreateItem("Send to a Friend") TrayCreateItem("") $aboutitem = TrayCreateItem("About") TrayCreateItem("") $exititem = TrayCreateItem("Exit") TraySetState() ; loop While 1 $msg = TrayGetMsg() TrayItemSetState($msg, $TRAY_UNCHECKED) ; every 3 hours check if the ini files timers are < condition to run the updates If _DateDiff("s", $iTimer, _NowCalc()) >= 10800 then ; check the status every 3 hours = 10800 sec $iTimer = _NowCalc() $ini = IniRead($MyWorkingDir & "\Config.ini", "MyProcess" ,"LastUpdate", "1970/01/01 00:00:00") if _DateDiff("s", $ini, _NowCalc()) >= 21600 then ; if last update is before 6 hours (21600 sec) run Update $hdl = Update () EndIf $iniStr = IniRead($MyWorkingDir & "\Config.ini", "MyProcess" ,"LastStrUpdate", "1970/01/01 00:00:00") if _DateDiff("s", $iniStr, _NowCalc()) >= 86400 then ; if last update is before 24 hours (86400 sec) run UpdateStr $hdl = UpdateStr() EndIf EndIf ; check Tray msg. Select Case $msg = 0 ContinueLoop Case $msg = $updateitem $hdl = Update () Case $msg = $MyProcessItem $oIE = _IECreate() _IENavigate($oIE, "http://www.MyProcess.com", 0) Case $msg = $sendafriend $oIE = _IECreate() _IENavigate($oIE, "http://www.MyProcess.com", 0) Case $msg = $aboutitem Msgbox(64, "About", "MyProcess") Case $msg = $exititem Exit EndSelect sleep (10) WEnd Share this post Link to post Share on other sites
seandisanti 6 Posted August 28, 2010 For some reason, the attached script works well for short times (few mins) but will NOT work for the 6-24 hours I need.what's it doing?Since my computer is set to hibernate every 2 hours, the actual testing I made was to run the complied exe, wait that my computer will get into hibernation, wake it up few ours later, and wait for the update to run , nothing happed. is it not waking from hibernate, is it not doing your update? Share this post Link to post Share on other sites
nadigo 0 Posted August 29, 2010 what's it doing?is it not waking from hibernate, is it not doing your update?after coming from hibernation it will not do the update. Share this post Link to post Share on other sites
seandisanti 6 Posted August 29, 2010 after coming from hibernation it will not do the update.ok, but it does wake up -that's a good thing. does the update portion work if you run it on its own? Share this post Link to post Share on other sites
nadigo 0 Posted August 29, 2010 ok, but it does wake up -that's a good thing. does the update portion work if you run it on its own? when I run it manual via the tray item it works. It seems like the condition: If _DateDiff("s", $iTimer, _NowCalc()) >= 10800 then ; check the status every 3 hours = 10800 sec $iTimer = _NowCalc() is never met. like the Global $iTimer = _NowCalc() is alway below 10800. can it be that the $iTimer var is been 'lost' from memory after hibernation ? or can it be that $msg = TrayGetMsg() TrayItemSetState($msg, $TRAY_UNCHECKED) is stock and will not get to the above condition ? advise ? Share this post Link to post Share on other sites