Aethec, I agree with you but I have used ccleaner over a thousand times and have yet encountered an issue.
pullmyefinger, Looks like I have solved your problem...
Here is the code I am using and it works perfectly. Well except for one bug I cannot seem to fix and I am wondering if you can help me find the issue... I'll post the code after I list the issue...
When I run the code the cleaner runs auto, then the registry cleaner starts. I run the registry one up to 3 times but for some reason on some computers the code crashes ccleaner on the second loop through. If it did it all the time I could likely find the issue but it is very odd.
;I use a batch file to detect if 32 or 64 bit system and run the appropriate version of the standalone version of ccleaner.
;Any suggestions or ideas to make this code better is appreciated. Thanks.
Here's the code:
AutoItSetOption("MustDeclareVars", 1)
Opt("SendKeyDelay", 100); pauses between sent keystrokes
Opt("WinDetectHiddenText", 1)
Opt("WinSearchChildren", 1)
Dim $Drive
Dim $AppWinTitle
$AppWinTitle = “Piriform CCleaner”
$Drive = StringLeft(@ScriptDir, 2)
OnAutoItStart()
ShellExecute($Drive & “\SST\Tools\1CCleaner\RunCCleaner_32_64.bat”) ;This is the location of ccleaner
WinWait($AppWinTitle)
WinActivate($AppWinTitle)
_WinWaitActive($AppWinTitle, “&Run Cleaner”)
BlockInput(1)
AdlibRegister(_CheckForApp($AppWinTitle), 2000)
ControlClick($AppWinTitle, “&Run Cleaner”, “Button2”, “main”)
BlockInput(0)
Sleep(500)
_WinWaitActive($AppWinTitle, “CLEANING COMPLETE”)
BlockInput(1)
ControlClick($AppWinTitle, “Re&gistry”, “Button5”, “main”)
BlockInput(0)
Sleep(500)
For $i = 1 To 3
_WinWaitActive($AppWinTitle, “&Scan for Issues”)
BlockInput(1)
ControlClick($AppWinTitle, “&Scan for Issues”, “Button2”, “main”)
BlockInput(0)
Sleep(500)
;sleep while the Cancel button is active…
While ControlCommand($AppWinTitle, “&Cancel Scan”, “Button2”, “IsEnabled”, “”)
Sleep(500)
WEnd
If ControlCommand($AppWinTitle, “&Fix selected issues…”, “Button3”, “IsEnabled”, “”) Then
Sleep(1000)
;_WinWaitActive($AppWinTitle, “&Fix selected issues…”)
BlockInput(1)
ControlClick($AppWinTitle, “&Fix selected issues…”, “Button3”, “main”)
BlockInput(0)
Sleep(1000)
If ControlCommand("", "Fix All Selected Issues", "[CLASS:Button; TEXT:Fix All Selected Issues; INSTANCE:1]", "IsVisible", "") Then
BlockInput(1)
ControlClick("", "", "[CLASS:Button; TEXT:Fix All Selected Issues; INSTANCE:1]", "main")
BlockInput(0)
While ControlCommand("", "Fix All Selected Issues", "[CLASS:Button; TEXT:Fix All Selected Issues; INSTANCE:1]", "IsEnabled", "")
Sleep(500)
WEnd
BlockInput(1)
ControlClick("", "", "[CLASS:Button; TEXT:Close; INSTANCE:1]", "main")
BlockInput(0)
ElseIf ControlCommand("", "Fix Issue", "[CLASS:Button; TEXT:Fix Issue; INSTANCE:1]", "IsVisible", "") Then
BlockInput(1)
ControlClick("", "", "[CLASS:Button; TEXT:Fix Issue; INSTANCE:1]", "main")
BlockInput(0)
While ControlCommand("", "Fix Issue", "[CLASS:Button; TEXT:Fix Issue; INSTANCE:1]", "IsEnabled", "")
Sleep(500)
WEnd
BlockInput(1)
ControlClick("", "", "[CLASS:Button; TEXT:Close; INSTANCE:1]", "main")
BlockInput(0)
EndIf
Else
;close CCLeaner
BlockInput(0)
AdlibUnRegister(_CheckForApp($AppWinTitle))
WinClose($AppWinTitle)
WinWaitClose($AppWinTitle)
Exit (0)
EndIf
Sleep(1000)
Next
;close CCLeaner
BlockInput(0)
AdlibUnRegister(_CheckForApp($AppWinTitle))
WinClose($AppWinTitle)
WinWaitClose($AppWinTitle)
Exit (0)
Func _WinWaitActive($title, $text = ‘’)
; window wait functions
While Not WinActive($title, $text)
WinWait($title, $text)
WinActivate($title, $text)
WinWaitActive($title, $text)
WEnd
WinSetOnTop($title, $text, 1)
EndFunc ;==>_WinWaitActive
Func OnAutoItStart()
; single script instance only
If WinExists(@ScriptName & ‘_Interpreter’) Then Exit
AutoItWinSetTitle(@ScriptName & ‘_Interpreter’)
EndFunc ;==>OnAutoItStart
Func _CheckForApp($title)
; Used to scan for something while program is running
; Use AdlibRegister(_CheckForApp($title), 2000) to start scanning
; Use AdlibUnregister(_CheckForApp($title)) to stop scanning
If Not WinExists($title) Then
BlockInput(0)
Exit (0)
;WinClose
EndIf
EndFunc ;==>_CheckForApp