feistcomputers

CCleaner Automation

6 posts in this topic

I am trying to automate about 5 programs to basically click the buttons i would click.  Should be pretty simple if you i knew more but just beginning and starting to get the hang of it.  I hate to bug you all but been working on this for 3hrs , testing, searching for info. and i'm stuck. Here is my code.


#RequireAdmin
Run (@ScriptDir & '\CCleaner.exe')
; Always use this, it does mapping using the window versus the the whole screen, because every computer can have diff. resolutions.
; have to change it in the info getter too. options/coordmode/windows
AutoItSetOption ('MouseCoordMode', 0)


;Waits for our window to come up
WinWait("Piriform CCleaner")
;When it see's it the windows gets activated right away.
WinActivate("Piriform CCleaner")
;primary means left click mouse, secondary means to right click. coord for where button is from info from mouse tab on into tool. 1 means 1 click.
MouseClick('primary', 727, 530, 1, 0)


; Close the temporary warning msgbox  - Got this to work , snippet i found on forum so figured use same for chrome waring also. 
    If WinWait('', 'Do not show me this message again', 4) Then
        WinActivate("", 'Do not show me this message again')
        ControlClick('', 'Do not show me this message again', 1, 'left', 1)
    EndIf
        ; Close the temporary chrome warning msgbox - comes up with closing program, it is set to button 1 just like first one, but can get past it now. 
    If WinWait('', 'Do you want CCleaner to close Google Chrome', 4) Then
       WinActivate("", 'Do you want CCleaner to close Google Chrome')
       ControlClick('', 'Do you want CCleaner to close Google Chrome', 1, 'left', 1)
    EndIf

Sleep (300)
WinWait("Piriform CCleaner")
WinActivate("Piriform CCleaner")
MouseClick('primary', 716, 521, 1, 0)  so if chromes not open i get to here. it does the clean. now how to i get it to watch for the " run cleaner button" to be active again and not greyed out. Once this shows active i can move on to next step but cant find much info on it.  tried looking for ifenabled.  I do alot of scans for virus infections. and waiting is part of the game for me. If i can get these to work that means less work and more time with my kids. GOAL  any help appreciated.  i watched tut.orial 9 & 10. Can you recommend any others for basic push buttons and wait secnario.  Thanks for any help. 

Capture.JPG

Share this post


Link to post
Share on other sites



Thankyou ComputerGroove, that just solved two my issues. Just one to go. I can put 5min wait timer on here if i have to do it. But i would rather have autoit see that button become ungreyed out and move onto the next step.  Can anyone please point me in the right direction. 

thanks for the help.

Share this post


Link to post
Share on other sites

Just a quick heads up on posting code, please use the add code icon"<>" in the toobar, e.g. your script:

#RequireAdmin
Run (@ScriptDir & '\CCleaner.exe')
; Always use this, it does mapping using the window versus the the whole screen, because every computer can have diff. resolutions.
; have to change it in the info getter too. options/coordmode/windows
AutoItSetOption ('MouseCoordMode', 0)


;Waits for our window to come up
WinWait("Piriform CCleaner")
;When it see's it the windows gets activated right away.
WinActivate("Piriform CCleaner")
;primary means left click mouse, secondary means to right click. coord for where button is from info from mouse tab on into tool. 1 means 1 click.
MouseClick('primary', 727, 530, 1, 0)


; Close the temporary warning msgbox  - Got this to work , snippet i found on forum so figured use same for chrome waring also. 
    If WinWait('', 'Do not show me this message again', 4) Then
        WinActivate("", 'Do not show me this message again')
        ControlClick('', 'Do not show me this message again', 1, 'left', 1)
    EndIf
        ; Close the temporary chrome warning msgbox - comes up with closing program, it is set to button 1 just like first one, but can get past it now. 
    If WinWait('', 'Do you want CCleaner to close Google Chrome', 4) Then
       WinActivate("", 'Do you want CCleaner to close Google Chrome')
       ControlClick('', 'Do you want CCleaner to close Google Chrome', 1, 'left', 1)
    EndIf

Sleep (300)
WinWait("Piriform CCleaner")
WinActivate("Piriform CCleaner")
MouseClick('primary', 716, 521, 1, 0)

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

From "Autoit Window Info" determine the color of the greyed button a hexidecimal representation of the color e.g.'c0c0c0'

Use something like PixelGetColor (see AutoIT Help for more information)

Usually something like: (Note haven't tested)

$Color_Gray = 'C0C0C0'
$Color_Green = '00FF00'

MouseClick('left', x, y)
While 1
  If Hex(PixelGetColor(x, y), 6) = $Color_Green Then ExitLoop
  Sleep(100)
Wend

 

Edited by VenusProject2
tight while loop

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