Jump to content
Sign in to follow this  

CCleaner registry

Recommended Posts



I am trying to make a script that automaticallly scans for registry issues and fixes them but i'm stuck, if i want the script to fix the issues it clicks on the 'fix selected issues' button but then a new window pops up with only window class information and it can't find the control buttons (control info says that the whole window is Class: Static and instance: 4).

Run("programs\CCleaner\CCleaner.exe /registry")
WinWaitActive("Piriform CCleaner")
WinActivate("Piriform CCleaner")
Controlclick("Piriform CCleaner", "", "[CLASSNN:Button2]")
While Not ControlCommand("Piriform CCleaner", "&Fix selected issues", "[CLASSNN:Button3]", "IsEnabled")
If ControlCommand("Piriform CCleaner", "", "[CLASSNN:Button3]", "IsEnabled") Then

ControlClick("Piriform CCleaner", "", "[CLASSNN:Button3]")

    $title = "[CLASS:#32770]"
    $fix = "Fix all Issues"

    WinWait($title, $fix)
ControlCommand($title, $fix, "[CLASSNN:Static4]")
    While ControlCommand($title, $fix, "[CLASSNN:Static4]", "IsEnabled")
    ControlClick($title, $fix, "[CLASSNN:Static5]")
WinClose("Piriform CCleaner")

Can you guys help me with this?

Share this post

Link to post
Share on other sites

Press the Alt key and see if there's a shortcut for fix all. If not check and see if fix all is selected by default.

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects
Cisco FinesseGithubIRC UDFWindowEx UDF


Share this post

Link to post
Share on other sites

I had a play with this last night. It's been on my todo list for ages. But hit a few brances I hadn't thought of and went to bed.

Like 69255 I used Control View to find the info and the Standard AU3Info to work out a few things that control view didn't help with.

69255's version didn't work for me as I save backups of the registry fixes.

So here is my little contribution to the subject.

If you have any addtions or problems let me know.

Opt("MustDeclareVars", 1)
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#cs ----------------------------------------------------------------------------

    AutoIt Version .:
    Author .........: John Morrison
    Script Version .:
    Name ...........: CCleaner Auto Registry cleaner
    Date ...........: 2012/3/7
    Modified .......: 2012/3/7
    Company ........:
    Copyright ......:
    Script Function :

#ce ----------------------------------------------------------------------------

#Region Includes

#EndRegion Includes

#Region Script Constants
Global Const $MY_NAME = "CCleaner"
Global Const $HOME = @ScriptDir & ""
#EndRegion Script Constants

#Region Script Globals

#EndRegion Script Globals

#Region Main Script
; *********************** MAIN ENTRY POINT ****************************

;Check if CCleaner is installed
If @error Then
    MsgBox(16, "ERROR", "CCleaner is not installed!" & @CRLF & @CRLF & "Script will now exit")

Local $iCount = 10
While $iCount ; Keep looping untill ALL registry fixes done or looped 10 times
    Run(GetInstalledPath("CCleaner") & "CCleaner.exe /registry")

    ;Click Scan button
    WinWait("Piriform CCleaner", "&Scan for Issues")
    WinExistsActivateWaitClick("Piriform CCleaner", "&Scan for Issues", "[CLASS:Button; INSTANCE:2]")

    ;Wait for scan to complete
    Sleep(500) ; Wait for scan to get started
    WinWait("Piriform CCleaner", "&Scan for Issues")

    If Not ControlCommand("Piriform CCleaner", "&Fix selected issues", "[CLASS:Button; INSTANCE:3]", "IsEnabled") Then
        ;All Reg problems removed
        MsgBox(0, "ALL CLEAN", "")

    WinWait("Piriform CCleaner", "&Fix selected issues")
    WinExistsActivateWaitClick("Piriform CCleaner", "&Fix selected issues", "[CLASS:Button; INSTANCE:3]")

    If WinWait("CCleaner", "Do you want to backup changes to the registry?", 2) Then
        ;DON'T SAVE Backup
        ;WinExistsActivateWaitClick("CCleaner", "Do you want to backup changes to the registry?", "[CLASS:Button; INSTANCE:2]")

        ;SAVE Backup
        WinExistsActivateWaitClick("CCleaner", "Do you want to backup changes to the registry?", "[CLASS:Button; INSTANCE:1]")
        WinWait("Save As")
        DirCreate(@MyDocumentsDir & "ccleaner");in case it isn't already created
        ControlSetText("Save As", "", "[CLASS:Edit; INSTANCE:1]", @MyDocumentsDir & "ccleaner" & ControlGetText("Save As", "", "[CLASS:Edit; INSTANCE:1]"))
        ;Click Save
        WinExistsActivateWaitClick("Save As", "", "[CLASS:Button; INSTANCE:2]")

    ;Fix (ALL) issues
    Global $hWnd = WinWait("[CLASS:#32770]", "Fix Issue")
    WinExistsActivateWaitClick("[CLASS:#32770]", "Fix Issue", "[CLASS:Button; INSTANCE:4]") ;Fix ALL/Fix Issue
    ;Wait for Close button to be enabled
    While Not ControlCommand("[CLASS:#32770]", "Fix Issue", "[CLASS:Button; INSTANCE:5]", "IsEnabled")
    WinExistsActivateWaitClick("[CLASS:#32770]", "Fix Issue", "[CLASS:Button; INSTANCE:5]") ;Close

    $iCount = $iCount - 1
WinClose("Piriform CCleaner")
WinWaitClose("Piriform CCleaner")

#EndRegion Main Script

#Region Utility Functions
; #FUNCTION# ====================================================================================================================
; Name...........: GetInstalledPath
; Description ...: Returns the installed path for specified program
; Syntax.........: GetInstalledPath($sProgamName)
; Parameters ....: $sProgamName    - Name of program to seaach for
;                                  - Must be exactly as it appears in the registry
; Return values .: Success - returns the install path
;                  Failure - 0
;                  |@Error  - 1 = Unable to find entry in registry
; Author ........: John Morrison aka Storm-E
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func GetInstalledPath($sProgamName)
    ; @error = 1 - Not installed
    ;Get Installed path
    Static $sInstalledPath = ""
    If $sInstalledPath = "" Then
        $sInstalledPath = RegRead("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall" & $sProgamName, "InstallLocation")
        If @error Then
            $sInstalledPath = ""
            Return SetError(1, 0, "")
    Return $sInstalledPath
EndFunc   ;==>GetInstalledPath

Func WinExistsActivateWaitClick($title, $text, $controlID)
    If WinExistsActivateWait($title, $text) Then
        Return ControlClick($title, $text, $controlID)
    Return False
EndFunc   ;==>WinExistsActivateWaitClick

Func WinExistsActivateWait($title, $text = "")
    ;Got sick of writting this over and over in scripts
    If WinExists($title, $text) Then
        ConsoleWrite("WinExists : $title=" & $title & " $text=" & $text & @CR)
        WinActivate($title, $text)
        WinWait($title, $text)
        Return True
    Return False
EndFunc   ;==>WinExistsActivateWait

#EndRegion Utility Functions

Hope it helps someone!

John Morrison



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