Jump to content

Imagesearch ? CCleaner


Recommended Posts

I have be working on this stuff since april on my own and i'm about ready to call it quits.  It should be possible to do.  If your good at scripting.  I'm getting better but need some help.  I can get the clicks to work but not the timer. Want to save as much time as i can. so instead of a timer that goes way over what is needed to run the scan or scans, i want to apply this to many programs i use for computer cleanups in my shop.  Can't get it to click next button when button becomes active again.  any help much appreciated. Here is my code. The closing of the browsers isnt working muchless the image detection. Maybe its not getting to it. would be nice if it would show you where it go stuck.  thankyou.

#RequireAdmin

;Gives you admin rights
; By doing this you can have folder anywhere just as long as exe is in same folder as script.
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)


While ProcessExists("iexplore.exe")
    ProcessClose("iexplore.exe")
    Sleep(100)
WEnd
While ProcessExists("safari.exe")
    ProcessClose("safari.exe")
    Sleep(100)
WEnd
While ProcessExists("microsoftedge.exe")
    ProcessClose("microsoftedge.exe")
    Sleep(100)
WEnd
While ProcessExists("firefox.exe")
    ProcessClose("firefox.exe")
    Sleep(100)
WEnd
While ProcessExists("chrome.exe")
    ProcessClose("chrome.exe")
    Sleep(100)
WEnd

;Waits for our window to come up
WinWait("Piriform CCleaner")
;When it see's it the windows gets activated right away.
WinActivate("Piriform CCleaner")
Sleep(900)
;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)


#include <ImageSearch.au3>
HotKeySet("p", "checkForImage")
global $y = 0, $x = 0
Func checkForImage()
Local $search = _ImageSearch('checkImage.bmp', 0, $x, $y, 0)
If $search = 1 Then
MouseMove($x, $y, 10)
EndIf
EndFunc
while 1
sleep(200)
WEnd



WinWait("Piriform CCleaner")
;When it see's it the windows gets activated right away.
WinActivate("Piriform CCleaner")
Sleep(300)
;Application tab click.
MouseClick('primary', 523, 151, 1, 0)

Sleep(3000)
MouseClick('primary', 275, 114, 1, 0)
Sleep(344)
WinWait("Piriform CCleaner")
;When it see's it the windows gets activated right away.
WinActivate("Piriform CCleaner")
MouseClick('primary', 716, 521, 1, 0)
Sleep(3000)
;goto reg
Send("!g")
;scan reg
Send('!s')
Sleep(3000)
Send('!f')
MouseClick('primary', 565, 520, 1, 0)
;scan reg
Send('!s')
Sleep(2000)
Send('!f')
MouseClick('primary', 565, 520, 1, 0)
WinClose

 

Link to comment
Share on other sites

Well for a start you have no error checking or debugging lines such as ConsoleWrite or MsgBox to indicate where you are in your script and what is failing.

You could add this to top of script to begin with.

Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info

Then when you hover mouse over tray Icon, it will show in a tooltip what file and code line your script is at.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

  • Moderators

@feistcomputers, why would you bang your head against the wall with Sends and Mouseclicks rather than using the command line parameters built into the product for you?

https://www.piriform.com/docs/ccleaner/advanced-usage/command-line-parameters

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

@Bert you look to be correct :>

Been a customer so long I forgot they don't support everything for the free version.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I have used the auto and only goes like seven seconds. Much to quick, and in my mind since i can not see it i feel i'm not doing a good job on the cleanup. Once i get this time figured out it will spill over into all my tools i would like to automate. I just cant get past this. And i have like 5 other programs i want to do but dont want to move on until i finish this. So without using the command line i want to get this functioning with autoit. If there is a tutorial to watch please point me in the direction.  I've tried different scripts but either i scripting it wrong  or ccleaner is a bit tuff. what info would you guys need to help me figure this out :)

Link to comment
Share on other sites

  • Moderators

@feistcomputers,  if you want people to help you with code, please post code or link to where you found it. Posting a picture does not give us everything needed to help; worse, it forces someone trying to help you to type all the code out manually.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I think I got some of it. It seemed to click first but then goto registry tab and sit but i hadn't really got that far before.  So I redid and hopefully fixed them all. But now it says.  

"D:\Shop-Server-Share\FC Scripts\CCleanerAuto\CCleaner.au3" (66) : ==> Duplicate function name.:
Func checkForImage()

Not sure tried to give same image a copy with diff name.  Not sure what its telling me or if rest of the script works.  Here it is.

Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info
#RequireAdmin

;Give you admin rights
; By doing this you can have folder anywhere just as long as exe is in same folder as script.
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)


While ProcessExists("iexplore.exe")
    ProcessClose("iexplore.exe")
    Sleep(100)
WEnd
While ProcessExists("safari.exe")
    ProcessClose("safari.exe")
    Sleep(100)
WEnd
While ProcessExists("microsoftedge.exe")
    ProcessClose("microsoftedge.exe")
    Sleep(100)
WEnd
While ProcessExists("firefox.exe")
    ProcessClose("firefox.exe")
    Sleep(100)
WEnd
While ProcessExists("chrome.exe")
    ProcessClose("chrome.exe")
    Sleep(100)
WEnd

;Waits for our window to come up
WinWait("Piriform CCleaner")
;When it see's it the windows gets activated right away.
WinActivate("Piriform CCleaner")
Sleep(3000)
;Clicking In Cleaner/Windows Tab, Run Cleaner button.
MouseClick('primary', 727, 530, 1, 0)

;waits for Run Cleaner button to become blue & active again.
#include <ImageSearch.au3>
HotKeySet("p", "checkForImage")
global $y = 0, $x = 0
Func checkForImage()
Local $search = _ImageSearch('checkImage.bmp', 0, $x, $y, 0)
If $search = 1 Then
MouseMove($x, $y, 10)
EndIf
EndFunc


WinWait("Piriform CCleaner")
;When it see's it the windows gets activated right away.
WinActivate("Piriform CCleaner")
Sleep(300)
;Application tab click.
MouseClick('primary', 279,109, 1, 0)
Sleep(3000)
;Clicking In Cleaner/Applications Tab, Run Cleaner button.
MouseClick('primary', 727, 530, 1, 0)

#include <ImageSearch.au3>
HotKeySet("p", "checkForImage")
global $y = 0, $x = 0
Func checkForImage()
Local $search = _ImageSearch('checkImage1.bmp', 0, $x, $y, 0)
If $search = 1 Then
MouseMove($x, $y, 10)
EndIf
EndFunc


;goto registry Tab
Send("!g")
;Push button "scan for issues" 1st scan of 2
Send('!s')

;waits for "Fix selected issues" button to become blue & active
#include <ImageSearch.au3>
HotKeySet("p", "checkForImage")
global $y = 0, $x = 0
Func checkForImage()
Local $search = _ImageSearch('fix.bmp', 0, $x, $y, 0)
If $search = 1 Then
MouseMove($x, $y, 10)
EndIf
EndFunc

;fix registry errors button
Send('!f')
Sleep(5000)
;Close button after fix
MouseClick('primary', 239, 226, 1, 0)

;Push button "scan for issues" 2nd scan of 2
Send('!s')
Sleep(2000)

;waits for "Fix selected issues" button to become blue & active
#include <ImageSearch.au3>
HotKeySet("p", "checkForImage")
global $y = 0, $x = 0
Func checkForImage()
Local $search = _ImageSearch('fix.bmp', 0, $x, $y, 0)
If $search = 1 Then
MouseMove($x, $y, 10)
EndIf
EndFunc

;fix registry errors button
Send('!f')
Sleep(5000)
;Close button after fix
MouseClick('primary', 239, 226, 1, 0)

WinClose

while 1
sleep(200)
WEnd

 

Link to comment
Share on other sites

Hey John, I'm confused.  I though you would have to put 

;waits for Run Cleaner button to become blue & active again.
#include <ImageSearch.au3>
HotKeySet("p", "checkForImage")
global $y = 0, $x = 0
Func checkForImage()
Local $search = _ImageSearch('checkImage.bmp', 0, $x, $y, 0)
If $search = 1 Then
MouseMove($x, $y, 10)
EndIf
EndFunc

every time you wanted to search for a picture or new picture. Is this not correct.  I want to thank you all to for helping me.  I have spent so much time trying to get this to work since april.  Doing it to save time, so i can start a virus removal and let it go.  Spend more time with my kids instead of working on computers til after they go to bed.  

Link to comment
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
 Share

×
×
  • Create New...