Thinkpad Posted March 7, 2012 Share Posted March 7, 2012 Hello, 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). #requireadmin Run("programs\CCleaner\CCleaner.exe /registry") WinWaitActive("Piriform CCleaner") WinActivate("Piriform CCleaner") Controlclick("Piriform CCleaner", "", "[CLASSNN:Button2]") WinWaitActive("[CLASSNN:Button3]") While Not ControlCommand("Piriform CCleaner", "&Fix selected issues", "[CLASSNN:Button3]", "IsEnabled") Sleep(5000) WEnd 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") Sleep(10) WEnd ControlClick($title, $fix, "[CLASSNN:Static5]") EndIf WinClose("Piriform CCleaner") Sleep(1000) Can you guys help me with this? Link to comment Share on other sites More sharing options...
rcmaehl Posted March 7, 2012 Share Posted March 7, 2012 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 WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
Chimaera Posted March 7, 2012 Share Posted March 7, 2012 Have a look here for info on ccleaner http://www.piriform.com/docs/ccleaner/advanced-usage/command-line-parameters Maybe there will be something to help If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
storme Posted March 8, 2012 Share Posted March 8, 2012 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.expandcollapse popup#AutoIt3Wrapper_Run_Debug_Mode=y Opt("MustDeclareVars", 1) #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Fileversion=1.0.0.0 #AutoIt3Wrapper_Res_LegalCopyright= #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version .: 3.3.6.1 Author .........: John Morrison Script Version .: 1.0.0.0 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 **************************** #RequireAdmin ;Check if CCleaner is installed GetInstalledPath("CCleaner") If @error Then MsgBox(16, "ERROR", "CCleaner is not installed!" & @CRLF & @CRLF & "Script will now exit") EndIf 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 ExitLoop MsgBox(0, "ALL CLEAN", "") EndIf 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]") ;SetPath 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]")) Sleep(500) ;Click Save WinExistsActivateWaitClick("Save As", "", "[CLASS:Button; INSTANCE:2]") EndIf ;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") Sleep(500) WEnd Sleep(500) WinExistsActivateWaitClick("[CLASS:#32770]", "Fix Issue", "[CLASS:Button; INSTANCE:5]") ;Close $iCount = $iCount - 1 WEnd WinClose("Piriform CCleaner") WinWaitClose("Piriform CCleaner") Exit #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) ;Written ; @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, "") EndIf EndIf Return $sInstalledPath EndFunc ;==>GetInstalledPath Func WinExistsActivateWaitClick($title, $text, $controlID) If WinExistsActivateWait($title, $text) Then Return ControlClick($title, $text, $controlID) EndIf 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 EndIf Return False EndFunc ;==>WinExistsActivateWait #EndRegion Utility FunctionsHope it helps someone!John MorrisonakaStorm-E Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E 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