cyanidemonkey Posted January 9, 2007 Share Posted January 9, 2007 I have a simple app that starts on user login/system start up. It check the last time the user scanned and if it is less than 7 days quits. If the last scan was over 7 days it idles about until it sees the log out window and then asks the user if they want to scan the computer before shut down. The problem I'm having is that if the last scan is over 7 days while it is idle it seems tobe taking up about 99% CPU! Code below, can someone tell me why my code is sucking up CPU resources? expandcollapse popup#include <GUIConstants.au3> #Include <date.au3> #NoTrayIcon $lastscan = IniRead(@ScriptDir & "\scans.ini","scan date","last scan","") If _DateDiff('d',$lastscan,_NowCalc()) <= 7 Then Exit 0 EndIf While 250 ;------ USER CLICKS LOG OFF ------; If WinExists("Log Off Windows") Then If _DateDiff( 'd',$lastscan,_NowCalc()) > 7 Then $ScanFirst = MsgBox(36, "ScanBoot", "It has been over a week since the last full system scan." & @CRLF & "Would you like ScanBoot to scan your computer now?" & @CRLF & "ScanBoot will restart your computer when finished.", 30) If $ScanFirst = 6 OR $ScanFirst = -1 Then Run(@ScriptDir & '\scanboot.exe') Exit 0 Else Shutdown(0) EndIf Else Exit 0 EndIf EndIf ;------ USER CLICKS SHUTDOWN ------; If WinExists("Shut Down Windows") Then WinKill("Shut Down Windows") If _DateDiff( 'd',$lastscan,_NowCalc()) > 7 Then $ScanFirst = MsgBox(36, "ScanBoot", "It has been over a week since the last full system scan." & @CRLF & "Would you like ScanBoot to scan your computer now?" & @CRLF & "ScanBoot will restart your computer when finished.", 30) If $ScanFirst = 6 OR $ScanFirst = -1 Then Run(@ScriptDir & '\scanboot.exe') Exit 0 Else Shutdown(0) EndIf Else Exit 0 EndIf EndIf Wend My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator Link to comment Share on other sites More sharing options...
theguy0000 Posted January 9, 2007 Share Posted January 9, 2007 add sleep (100) to the end of the loop. and just a question, why do you use "While 250" ? The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
cyanidemonkey Posted January 9, 2007 Author Share Posted January 9, 2007 There was my confusion :"> I thought while 1 was every millisecond, so I figured if I made it 250 it would loop every 250 milliseconds... Cheers for the help. My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator 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