Sparrowlord Posted July 28, 2007 Share Posted July 28, 2007 What I'm trying to do is this. #1. Search for a window named "Hey" but only search for that window once every five minutes. #2. Then after an hour close a window named "Main" and reload it. But I got caught up with the timers, heres what I'm thinking of: $5minutetimer = TimerInit() $1hourtimer = TimerInit() While 1 $5minutediff = TimerDiff($5minutetimer) $1hourdiff = TimerDiff($1hourtimer) If $5minutediff > 300000 Then If WinExists("Hey") Then WinActivate("Hey") ControlClick("Hey", "", "Button1") $5minutetimer = TimerInit() EndIf EndIf If $1hourdiff > 3600000 Then WinClose("Main") WinWaitClose("Main") Sleep("10000") Run($path) $1hourtimer = TimerInit() EndIf WEnd Now I have 2 questions. #1. Will this cause a heavy load on my pc looking for those windows? #2. Will the above code work? I just typed it now by hand and I don't have the time to run/check it, speaking of that im heading off to work now >< I would appreciate any help Thanks, Spar Link to comment Share on other sites More sharing options...
Tobei Posted July 28, 2007 Share Posted July 28, 2007 toss in a sleep ( 10 ) somewhere in the loop outside of the if statements. I would change the TimerDiff($5minutetimer) and TimerDiff($1hourtimer) references to Integers instead of leaving them as floating point integers. But yea, without a sleep statement in the loop it will go crazy on your computer. The code should work by the looks of it, provided $path is defined properly. Link to comment Share on other sites More sharing options...
cramaboule Posted July 28, 2007 Share Posted July 28, 2007 Have you tried @MIN and @HOUR ? Cramaboule. My Autoit programs: MAC Address - - Delete Temp Files - - Ping Test - - Play Video with VLC full screen dual monitors - - Set IP - - Pics Converter - - AutoUpdater - - CPU Usage - - Ending Script Nicely - - GDI+ GUI crossfades (slide transitions) - - Beamer - - Search and Search in Files - - Silent Ninite Others: Export Icons into Dll - - My website Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 28, 2007 Share Posted July 28, 2007 What I'm trying to do is this. #1. Search for a window named "Hey" but only search for that window once every five minutes. #2. Then after an hour close a window named "Main" and reload it. ; ... Now I have 2 questions. #1. Will this cause a heavy load on my pc looking for those windows? #2. Will the above code work? I just typed it now by hand and I don't have the time to run/check it, speaking of that im heading off to work now >< I would appreciate any help Thanks, Spar Just a sleep(100) to let the CPU get away from your script's loop for a while, as Tobei said. The reset of the 5min timer needed to be outside of the If/EndIf for "Hey". I also removed unnecessary saving of the TimerDiff() to a variable, but that's personal just preference: $5minutetimer = TimerInit() $1hourtimer = TimerInit() While 1 If TimerDiff($5minutetimer) > (5 * 60 * 1000) Then If WinExists("Hey") Then WinActivate("Hey") ControlClick("Hey", "", "Button1") EndIf $5minutetimer = TimerInit() EndIf If TimerDiff($1hourtimer) > (60 * 60 * 1000) Then WinClose("Main") WinWaitClose("Main") Sleep("10000") Run($path) $1hourtimer = TimerInit() EndIf Sleep(100) WEnd Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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