feistcomputers

Imagesearch ? CCleaner

16 posts in this topic

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

 

Share this post


Link to post
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.

1 person likes this

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

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

@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

 


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

@Bert you look to be correct :>

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


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

This works for me using the free version...

shellexecute("c:\program files\ccleaner\ccleaner.exe ","/auto")

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I had found that script rummaging thru the forums.  2yrs old. How would i fix it.

 

Now i'm blessed with errors. download beta config file to editor.  Not sure if that is the answer or not. Didnt work.      uuuugggggg

Capture.JPG

Edited by feistcomputers

Share this post


Link to post
Share on other sites

@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.


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
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

 

Share this post


Link to post
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.  

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

  • Similar Content

    • Miliardsto
      By Miliardsto
      Hello i got problem with ImageSearchDll.dll
      It works for me perfect always I made program which one use a lot of ImageSearch funcs on 64bit.
      I got 64bit and i copied to c:/Windows - ImageSearchDll.dll 64bit version
      But I encountered some friends got 32bit OS and then if I compile program for 32bit then they put ImageSearchDll.dll 32bit ver on windows dir and program crash when function is call.
      it happens always :/
       
      How to run this func on 32bit?
    • SaeidN
      By SaeidN
      Hi,
      I saw a couple topics about both mousedrag and imagesearch in background or minimized window, but none of them has the solution, and they were old topics.
      So I wanted to ask whether there is a way to mouse drag without the cursor to move, (I want to use mouse when mousedrag is working on a window). I don't know whether I can mix ControlMove with some other stuff or any other way?
      And also for the image search, is there any way to search for image (or pixel) in a background or minimized window? I thought maybe there is a au3 or dll or ... file for doing this.
      Another question I have: Any way to pinch zoom (two fingers) a window like "windows photo viewer" to zoom in or out? I saw something almost the same here, but not what I want.
      I appreciate it.
    • computergroove
      By computergroove
      I am trying to integrate imagesearch into a script I am making. When I try to compile the script I get the following inside imagesearch.au3 under all 4 of the imagesearch.au3 defined functions:
      "Error: Missing separator character before keyword"
      I tried the beta version of Autoit and it is doing the same thing. I am using the x32 version of the imagesearch.au3 found here - https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwiUmsrEsLzPAhWs7YMKHS9MClQQFggfMAA&url=https%3A%2F%2Fwww.autoitscript.com%2Fforum%2Ftopic%2F148005-imagesearch-usage-explanation%2F&usg=AFQjCNFwpFnZMxVK9H4cDASRnjiB-65gOw&bvm=bv.134495766,d.amc
      I have put the imagesearchDLL.dll in both the includes directory and the system32 directory. I am using x64 Windows 8.1 Pro. I cant see anything wrong. Please help.
    • Reizvoller
      By Reizvoller
      Hello,
      I am back once again to ask for assistance. I am just trying to fool around with the "ImageSearch" function in order to detect when certain elements appear on my active window to then respond to. To begin testing this I simply cut out a small segment of my background, saved it as a BMP, and used that as the bmp for the search function. I had hoped for it to just run through quickly and say it found it and spit out the X Y coords of where it was found. Instead I am getting this : http://screencast.com/t/MD9aOzPhETE
      Here's my script thus far :
      #Include <msgBoxConstants.au3> #Include <ImageSearch.au3> global $x = 0 global $y = 0 CheckForImage () Func checkForImage () Local $Search = _ImageSearchArea ('ninjaCheck.bmp', 1, 0, 0, 1366, 768, $x, $y, 100) If $Search = 1 Then MsgBox ($IDOK,"Found",$resultPosition) EndIf EndFunc While 1 Sleep (10) WEnd What I would like assistance with is how do I "Debug" this in order to see where/why it is failing.
      I've reviewed https://www.autoitscript.com/wiki/FAQ#How_can_I_debug_my_script.3F but I am not entirely sure how to apply the information. If I could get a return on "Hey, this Func or This Line is where I died" , that would be awesome.
      Any suggestions on how I can tackle this issue?
      Thank you for your time!
      -Reiz
       
      checkNinja.bmp is " " around it now and it has the same result 
    • avidovi
      By avidovi
      Hello friends,
      i need your help and advice regarding the image search function.
      I need to click an image on a web site. after using the image search function i am getting the following error, on the image search function
      if $result[0]="0" then return 0 if $result^ ERROR I am using the x64 configuration with the following files attached
      thanks for helping..
      ImageSearch 64 bit.rar