Sign in to follow this  
Followers 0
slightly_abnormal

automate process of ccleaner..

13 posts in this topic

I got ccleaner to do it's thing but when it finishes, i want it to close.. i'm stumped on how to do this..

Run("C:\Program Files\CCleaner\ccleaner.exe", "", @SW_HIDE)
Opt("WinTitleMatchMode", 4)
WinWait("CCleaner"," &Run Cleaner ")
ControlClick("CCleaner"," &Run Cleaner ","ThunderRT6CommandButton2")
WinSetState("CCleaner","",@SW_MINIMIZE)
WinWait("CCleaner", "", 20)
If WinExists("CCleaner", "Cleaning Complete") Then
    ProcessClose("ccleaner.exe")
EndIf

Share this post


Link to post
Share on other sites



If you look at the code from Valuater's XPClean you may be able to figure it out.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

If you look at the code from Valuater's XPClean you may be able to figure it out.

i'm lost..

Share this post


Link to post
Share on other sites

;Dutch  version of the automated download & install script.

Global $fileExists
$fileExists =  FileExists(@ProgramFilesDir & "\CCleaner\ccleaner.exe")
    
While 1 

If $fileExists = 1 then 
    call ("run_program")
    Exit
EndIf

If $fileExists = 0 then
        
        $func1 = MsgBox(4100, "", "Crap Cleaner is not installed,  Do you wish to download and install?")
    
        If $func1 = 7 Then Exit
        If $func1 = 6 Then

            Sleep(200)
    
    dim $Size
    $Size=InetGetSize("http://download.ccleaner.com/download1198bin.asp")
    ProgressOn("Crap Cleaner","Downloading")
    $r=InetGet("http://download.ccleaner.com/download1198bin.asp", @DesktopDir & "\ccsetup119.exe" , 0, 1)
    if $r=0 then 
        msgbox(0,"Error","Cant connect to the internet!!")
        Exit
    EndIf
    
    While @InetGetActive

        ProgressSet(@InetGetBytesRead / $Size * 100,Round( @InetGetBytesRead / $Size * 100,0) & " %")
        Sleep(250)
    Wend
    ProgressOff()


Sleep (200)

Run(@DesktopDir & "\ccsetup119.exe")
Sleep(200)
Send("!u")

WinWaitActive ( "Installer Language", "", 2)
WinSetOnTop ( "Installer Language", "Please select a language.", 1)
WinActivate ( "Installer Language" )

Sleep (300)
ControlFocus("Installer Language", "", 1002)
ControlClick("Installer Language", "", 1002, "left", 1)
Sleep (300)
Send ("e")
Sleep (300)
Send ("{ENTER}")
Sleep (300)

ControlFocus("Installer Language", "OK", 1)
ControlClick("Installer Language", "OK", 1, "left", 1)

WinWaitActive("CCleaner v1.19 Setup")
Sleep(200)

Send("!n")
Sleep(100)
Send("!a")
Sleep(100)
Send("!n")
Sleep(100)
Send("!i")
Sleep(2000)
Send("!f")
Sleep(1000)

While 1
    $func1 = ControlCommand("CCleaner v1.19 Setup", "$Finish", 1, "IsEnabled", "")
    If $func1 = 1 Then ExitLoop
    If $func1 = 0 Then
        Sleep(200)
    EndIf
WEnd

Sleep(2000)
ControlFocus("CCleaner v1.19 Setup", "&Finish", 1)
ControlClick("CCleaner v1.19 Setup", "&Finish", 1, "left", 1)
MsgBox(64, "Auto-CC", "Installation completed, Deleting downloaded file..", 4)
FileDelete(@DesktopDir & "\ccsetup119.exe" )
Sleep(2000)

; Run the newly installed program and adjust some setting for future use.

Run(@ProgramFilesDir & "\CCleaner\ccleaner.exe")
WinWaitActive("CCleaner")

; Begin cleaning of the windows section

ControlFocus("CCleaner", "Run Cleaner", 3)
ControlClick("CCleaner", "Run Cleaner", 3, "left", 1)

Sleep (200)

ControlFocus("", "Do not show me this message again", 1)
ControlClick("", "Do not show me this message again", 1, "left", 1)

Sleep (50)  

ControlFocus("", "OK", 4)
ControlClick("", "OK", 4, "left", 1)

Sleep (50)

; Wait for button to become active then continue

While 1
    If ControlCommand("CCleaner", "Run Cleaner", 3, "IsEnabled", "") Then ExitLoop
WEnd

For $i = 1 To 8
    Send("{TAB}")
    Sleep(100)
Next
Send("{RIGHT}")
Sleep(100)

ControlFocus("CCleaner", "Run Cleaner", 3)
ControlClick("CCleaner", "Run Cleaner", 3, "left", 1)

Sleep (200)

ControlFocus("", "Do not show me this message again", 1)
ControlClick("", "Do not show me this message again", 1, "left", 1)

Sleep (50)  

ControlFocus("", "OK", 4)
ControlClick("", "OK", 4, "left", 1)

Sleep (50)

; Wait for button to become active then continue

While 1
    If ControlCommand("CCleaner", "Run Cleaner", 3, "IsEnabled", "") Then ExitLoop
WEnd

; Begin cleaning errors

For $i = 1 To 8
    Send("{TAB}")
    Sleep(100)
Next
Send("{RIGHT}")
Sleep(100)

ControlFocus("CCleaner", "Scan for Issues", 3)
ControlClick("CCleaner", "Scan for Issues", 3, "left", 1)

Sleep(2000)

WinWaitActive("CCleaner")

; Wait for button to become active then continue

While 1
    $func1 = ControlCommand("CCleaner", "Fix selected issues...", 4, "IsEnabled", "")
    $func2 = ControlCommand("CCleaner", "Exit", 6, "IsEnabled", "")
    
    If $func1 = 1 And $func2 = 1 Then ExitLoop
    If $func1 = 0 And $func2 = 1 Then
        Sleep(2000)
        MsgBox(64, "Auto-CC", "Cleaning Completed")
        ControlFocus("CCleaner", "Exit", 6)
        ControlClick("CCleaner", "Exit", 6, "left", 1)
        Sleep(2000)
        Exit
    EndIf
WEnd

Sleep(2000)

ControlFocus("CCleaner", "Fix selected issues...", 4)
ControlClick("CCleaner", "Fix selected issues...", 4, "left", 1)

Sleep(300)

Send("!n")

WinWaitActive("Fix issues")
Sleep(100)

ControlFocus("Fix issues", "Fix selected issues...", 3)
ControlClick("Fix issues", "Fix selected issues...", 3, "left", 1)

Sleep(300)

Send("{ENTER}")

Sleep(300)

ControlFocus("Fix issues", "Exit", 5)
ControlClick("Fix issues", "Exit", 5, "left", 1)

Sleep(300)

ControlFocus("CCleaner", "Exit", 6)
ControlClick("CCleaner", "Exit", 6, "left", 1)

Sleep(300)

MsgBox(64, "Auto-CC", "Cleaning Completed")

Exit
EndIf
EndIf
WEnd

;Section if allready installed

Func run_program()

Run(@ProgramFilesDir & "\CCleaner\ccleaner.exe")
WinWaitActive("CCleaner")

; Begin cleaning of the windows section

ControlFocus("CCleaner", "Run Cleaner", 3)
ControlClick("CCleaner", "Run Cleaner", 3, "left", 1)

Sleep (200)

; Wait for button to become active then continue

While 1
    If ControlCommand("CCleaner", "Run Cleaner", 3, "IsEnabled", "") Then ExitLoop
WEnd

; Begin cleaning the applications section
; Tab 8 times, with 100 sleep between.

For $i = 1 To 8
    Send("{TAB}")
    Sleep(100)
Next
Send("{RIGHT}")
Sleep(100)

ControlFocus("CCleaner", "Run Cleaner", 3)
ControlClick("CCleaner", "Run Cleaner", 3, "left", 1)

Sleep (200)

; Wait for button to become active then continue

While 1
    If ControlCommand("CCleaner", "Run Cleaner", 3, "IsEnabled", "") Then ExitLoop
WEnd

; Begin cleaning errors

For $i = 1 To 8
    Send("{TAB}")
    Sleep(100)
Next
Send("{RIGHT}")
Sleep(100)

ControlFocus("CCleaner", "Scan for Issues", 3)
ControlClick("CCleaner", "Scan for Issues", 3, "left", 1)

Sleep(2000)

WinWaitActive("CCleaner")

; Wait for button to become active then continue

While 1
    $func1 = ControlCommand("CCleaner", "Fix selected issues...", 4, "IsEnabled", "")
    $func2 = ControlCommand("CCleaner", "Exit", 6, "IsEnabled", "")
    
    If $func1 = 1 And $func2 = 1 Then ExitLoop
    If $func1 = 0 And $func2 = 1 Then
        Sleep(2000)
        MsgBox(64, "Auto-CC", "Cleaning Completed")
        ControlFocus("CCleaner", "Exit", 6)
        ControlClick("CCleaner", "Exit", 6, "left", 1)
        Sleep(2000)
        Exit
    EndIf
WEnd

Sleep(2000)

ControlFocus("CCleaner", "Fix selected issues...", 4)
ControlClick("CCleaner", "Fix selected issues...", 4, "left", 1)

Sleep(300)

Send("!n")

WinWaitActive("Fix issues")
Sleep(100)

ControlFocus("Fix issues", "Fix selected issues...", 3)
ControlClick("Fix issues", "Fix selected issues...", 3, "left", 1)

Sleep(300)

Send("{ENTER}")

Sleep(300)

ControlFocus("Fix issues", "Exit", 5)
ControlClick("Fix issues", "Exit", 5, "left", 1)

Sleep(300)

ControlFocus("CCleaner", "Exit", 6)
ControlClick("CCleaner", "Exit", 6, "left", 1)

Sleep(300)

MsgBox(64, "Auto-CC", "Cleaning Completed")

EndFunc
    
Exit

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

;Dutch  version of the automated download & install script.

Global $fileExists
$fileExists =  FileExists(@ProgramFilesDir & "\CCleaner\ccleaner.exe")
    
While 1 

If $fileExists = 1 then 
    call ("run_program")
    Exit
EndIf

If $fileExists = 0 then
        
        $func1 = MsgBox(4100, "", "Crap Cleaner is not installed,  Do you wish to download and install?")
    
        If $func1 = 7 Then Exit
        If $func1 = 6 Then

            Sleep(200)
    
    dim $Size
    $Size=InetGetSize("http://download.ccleaner.com/download1198bin.asp")
    ProgressOn("Crap Cleaner","Downloading")
    $r=InetGet("http://download.ccleaner.com/download1198bin.asp", @DesktopDir & "\ccsetup119.exe" , 0, 1)
    if $r=0 then 
        msgbox(0,"Error","Cant connect to the internet!!")
        Exit
    EndIf
    
    While @InetGetActive

        ProgressSet(@InetGetBytesRead / $Size * 100,Round( @InetGetBytesRead / $Size * 100,0) & " %")
        Sleep(250)
    Wend
    ProgressOff()
Sleep (200)

Run(@DesktopDir & "\ccsetup119.exe")
Sleep(200)
Send("!u")

WinWaitActive ( "Installer Language", "", 2)
WinSetOnTop ( "Installer Language", "Please select a language.", 1)
WinActivate ( "Installer Language" )

Sleep (300)
ControlFocus("Installer Language", "", 1002)
ControlClick("Installer Language", "", 1002, "left", 1)
Sleep (300)
Send ("e")
Sleep (300)
Send ("{ENTER}")
Sleep (300)

ControlFocus("Installer Language", "OK", 1)
ControlClick("Installer Language", "OK", 1, "left", 1)

WinWaitActive("CCleaner v1.19 Setup")
Sleep(200)

Send("!n")
Sleep(100)
Send("!a")
Sleep(100)
Send("!n")
Sleep(100)
Send("!i")
Sleep(2000)
Send("!f")
Sleep(1000)

While 1
    $func1 = ControlCommand("CCleaner v1.19 Setup", "$Finish", 1, "IsEnabled", "")
    If $func1 = 1 Then ExitLoop
    If $func1 = 0 Then
        Sleep(200)
    EndIf
WEnd

Sleep(2000)
ControlFocus("CCleaner v1.19 Setup", "&Finish", 1)
ControlClick("CCleaner v1.19 Setup", "&Finish", 1, "left", 1)
MsgBox(64, "Auto-CC", "Installation completed, Deleting downloaded file..", 4)
FileDelete(@DesktopDir & "\ccsetup119.exe" )
Sleep(2000)

; Run the newly installed program and adjust some setting for future use.

Run(@ProgramFilesDir & "\CCleaner\ccleaner.exe")
WinWaitActive("CCleaner")

; Begin cleaning of the windows section

ControlFocus("CCleaner", "Run Cleaner", 3)
ControlClick("CCleaner", "Run Cleaner", 3, "left", 1)

Sleep (200)

ControlFocus("", "Do not show me this message again", 1)
ControlClick("", "Do not show me this message again", 1, "left", 1)

Sleep (50)  

ControlFocus("", "OK", 4)
ControlClick("", "OK", 4, "left", 1)

Sleep (50)

; Wait for button to become active then continue

While 1
    If ControlCommand("CCleaner", "Run Cleaner", 3, "IsEnabled", "") Then ExitLoop
WEnd

For $i = 1 To 8
    Send("{TAB}")
    Sleep(100)
Next
Send("{RIGHT}")
Sleep(100)

ControlFocus("CCleaner", "Run Cleaner", 3)
ControlClick("CCleaner", "Run Cleaner", 3, "left", 1)

Sleep (200)

ControlFocus("", "Do not show me this message again", 1)
ControlClick("", "Do not show me this message again", 1, "left", 1)

Sleep (50)  

ControlFocus("", "OK", 4)
ControlClick("", "OK", 4, "left", 1)

Sleep (50)

; Wait for button to become active then continue

While 1
    If ControlCommand("CCleaner", "Run Cleaner", 3, "IsEnabled", "") Then ExitLoop
WEnd

; Begin cleaning errors

For $i = 1 To 8
    Send("{TAB}")
    Sleep(100)
Next
Send("{RIGHT}")
Sleep(100)

ControlFocus("CCleaner", "Scan for Issues", 3)
ControlClick("CCleaner", "Scan for Issues", 3, "left", 1)

Sleep(2000)

WinWaitActive("CCleaner")

; Wait for button to become active then continue

While 1
    $func1 = ControlCommand("CCleaner", "Fix selected issues...", 4, "IsEnabled", "")
    $func2 = ControlCommand("CCleaner", "Exit", 6, "IsEnabled", "")
    
    If $func1 = 1 And $func2 = 1 Then ExitLoop
    If $func1 = 0 And $func2 = 1 Then
        Sleep(2000)
        MsgBox(64, "Auto-CC", "Cleaning Completed")
        ControlFocus("CCleaner", "Exit", 6)
        ControlClick("CCleaner", "Exit", 6, "left", 1)
        Sleep(2000)
        Exit
    EndIf
WEnd

Sleep(2000)

ControlFocus("CCleaner", "Fix selected issues...", 4)
ControlClick("CCleaner", "Fix selected issues...", 4, "left", 1)

Sleep(300)

Send("!n")

WinWaitActive("Fix issues")
Sleep(100)

ControlFocus("Fix issues", "Fix selected issues...", 3)
ControlClick("Fix issues", "Fix selected issues...", 3, "left", 1)

Sleep(300)

Send("{ENTER}")

Sleep(300)

ControlFocus("Fix issues", "Exit", 5)
ControlClick("Fix issues", "Exit", 5, "left", 1)

Sleep(300)

ControlFocus("CCleaner", "Exit", 6)
ControlClick("CCleaner", "Exit", 6, "left", 1)

Sleep(300)

MsgBox(64, "Auto-CC", "Cleaning Completed")

Exit
EndIf
EndIf
WEnd

;Section if allready installed

Func run_program()

Run(@ProgramFilesDir & "\CCleaner\ccleaner.exe")
WinWaitActive("CCleaner")

; Begin cleaning of the windows section

ControlFocus("CCleaner", "Run Cleaner", 3)
ControlClick("CCleaner", "Run Cleaner", 3, "left", 1)

Sleep (200)

; Wait for button to become active then continue

While 1
    If ControlCommand("CCleaner", "Run Cleaner", 3, "IsEnabled", "") Then ExitLoop
WEnd

; Begin cleaning the applications section
; Tab 8 times, with 100 sleep between.

For $i = 1 To 8
    Send("{TAB}")
    Sleep(100)
Next
Send("{RIGHT}")
Sleep(100)

ControlFocus("CCleaner", "Run Cleaner", 3)
ControlClick("CCleaner", "Run Cleaner", 3, "left", 1)

Sleep (200)

; Wait for button to become active then continue

While 1
    If ControlCommand("CCleaner", "Run Cleaner", 3, "IsEnabled", "") Then ExitLoop
WEnd

; Begin cleaning errors

For $i = 1 To 8
    Send("{TAB}")
    Sleep(100)
Next
Send("{RIGHT}")
Sleep(100)

ControlFocus("CCleaner", "Scan for Issues", 3)
ControlClick("CCleaner", "Scan for Issues", 3, "left", 1)

Sleep(2000)

WinWaitActive("CCleaner")

; Wait for button to become active then continue

While 1
    $func1 = ControlCommand("CCleaner", "Fix selected issues...", 4, "IsEnabled", "")
    $func2 = ControlCommand("CCleaner", "Exit", 6, "IsEnabled", "")
    
    If $func1 = 1 And $func2 = 1 Then ExitLoop
    If $func1 = 0 And $func2 = 1 Then
        Sleep(2000)
        MsgBox(64, "Auto-CC", "Cleaning Completed")
        ControlFocus("CCleaner", "Exit", 6)
        ControlClick("CCleaner", "Exit", 6, "left", 1)
        Sleep(2000)
        Exit
    EndIf
WEnd

Sleep(2000)

ControlFocus("CCleaner", "Fix selected issues...", 4)
ControlClick("CCleaner", "Fix selected issues...", 4, "left", 1)

Sleep(300)

Send("!n")

WinWaitActive("Fix issues")
Sleep(100)

ControlFocus("Fix issues", "Fix selected issues...", 3)
ControlClick("Fix issues", "Fix selected issues...", 3, "left", 1)

Sleep(300)

Send("{ENTER}")

Sleep(300)

ControlFocus("Fix issues", "Exit", 5)
ControlClick("Fix issues", "Exit", 5, "left", 1)

Sleep(300)

ControlFocus("CCleaner", "Exit", 6)
ControlClick("CCleaner", "Exit", 6, "left", 1)

Sleep(300)

MsgBox(64, "Auto-CC", "Cleaning Completed")

EndFunc
    
Exit

8)

i still doNT see it :o wheres the if done cleaning temp then close function? i'm using versopn 1.26.218.. i think they remove the exit after changing interface..

i feel stupid.

Edited by slightly_abnormal

Share this post


Link to post
Share on other sites

i still doNT see it :o wheres the if done cleaning temp then close function? i'm using versopn 1.26.218.. i think they remove the exit after changing interface..

i feel stupid.

thats an entire script that will install and run CCleaner

if it is installed, it will just run it

you may just need the last few lines

i thiought i would show you the whole thing.... if there was any part you could use

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

thats an entire script that will install and run CCleaner

if it is installed, it will just run it

you may just need the last few lines

i thiought i would show you the whole thing.... if there was any part you could use

8)

okay I tried the script it said "No issues were selected" like i said i believe i have the wrong version.. can i just exit ccleaner after its finished with ascript?

http://www.swteam.info/uploads/1109702908_...aner%5B1%5D.jpg >before gui change

http://filehippo.com/screenshot/ccleaner/780_1/after gui change

Share this post


Link to post
Share on other sites

this should have worked

ProcessClose("ccleaner.exe")

check each line towards the end of your script to make sure that this line is getting executed

i use Msgbox(0,'',"OK")

that simple

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

For just doing a auto clean, then you can just do it this way.

RunWait(@ProgramFilesDir & '\ccleaner\ccleaner.exe /auto')

Share this post


Link to post
Share on other sites

For just doing a auto clean, then you can just do it this way.

RunWait(@ProgramFilesDir & '\ccleaner\ccleaner.exe /auto')
thats cool! thanks mhz,

I guess checking out the comand line parameters are a lot of help!

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

i still doNT see it :o wheres the if done cleaning temp then close function? i'm using versopn 1.26.218.. i think they remove the exit after changing interface..

i feel stupid.

CCleaner has a selfclose option .. check it

(in options >>advanced >> close program after cleaning)

maybe for ALL languages is better to use :

ControlFocus ( "CCleaner","" , "ThunderRT6CommandButton2" )

ControlClick ( "CCleaner", "" , "ThunderRT6CommandButton2","left" )

instead

ControlFocus("CCleaner", "Run Cleaner", 3)

ControlClick("CCleaner", "Run Cleaner", 3, "left", 1)

EDIT

I see now vou get it in the command line but vou cancheck it also in

the ccleaner options

Edited by Lapo

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Or Just:

ControlClick ( "CCleaner", "" , "ThunderRT6CommandButton2")
:o

Edit:

Or since you said "All Languages"

Global $PRIMARY, $SECONDARY
_LeftOrRight($PRIMARY, $SECONDARY)

Func _LeftOrRight(ByRef $PRIMARY, ByRef $SECONDARY)
    Local $k
    $k = RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "SwapMouseButtons")
    If $k = 1 Then
        $PRIMARY = "right"
        $SECONDARY = "left"
    Else
        $PRIMARY = "left"
        $SECONDARY = "right"
    EndIf
EndFunc 

ControlClick( "CCleaner", "" , "ThunderRT6CommandButton2", $PRIMARY)
And probably should use Opt('WinTitleMatchMode', 4) - 'classname=Class' << for title, don't know if it is actually CCleaner in every language :geek:... Edited by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

This is what I use for my nightly maintenance script:

Func CrapCleaner()
    RunWait('"C:\Program Files\CCleaner\ccleaner.exe" /AUTO')
    Sleep(5000)
EndFunc

Just call the function and crap cleaner will silently run, clean and quit.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0