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   ipify 

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

    • knuxfighter
      By knuxfighter
      Hello. I've been working with Imagesearch library lately and it did a good work, although I moved to a new PC and didn't copy the old files with me so I downloaded the Imagesearch from the following post
       hoping that it will work. It doesn't though. First time I when I use (run as subscript to my code) the Imagesearch.au3, Scite finds errors (missing spaces). Ctrl+T (scite tidy) fixes these missing spaces but the script returns the following error on every run after:
      _ImageSearch('search.bmp', 0, $x, $y, 0) outputs
       
      "C:\Users\Knuckles\Desktop\AutoIt\include\ImageSearch.au3" (44) : ==> Subscript used on non-accessible variable.: If $result[0] = "0" Then Return 0 If $result^ ERROR no matter if I put the searched bmp in the script folder or folder img in the script directory. Also, it doesn't matter if the searched image on screen or not, it returns the same.

      Can you provide me any help please? I remember having these problems 2 years ago when I first met the imagesearch library also (I fixed it somehow though in that time). Seems nothing changed.

      Using this version posted in the following post gives the same error:
      Also I run windows 10 64bit and I have no shell options for script editing, running as x86 or whatever as I used to have on windows xp/7. I went through some steps like deleting a key in registry and I even reinstalled autoit and scite but that only resulted to au3 as unrecognized file format and not in getting back the menus and the icon on au3 files. Any thoughts on this?

      Edit: Installing 64-bit AutoIt and using 64bit ImageSearch is no change.
      code.au3

      FOUND WORKING: http://www.codebot.de/index.php/Thread/12713-Imagesearch-au3-funktioniert-nicht/
       but why is this one working and the original aren't? :(
    • masterland
      By masterland
      Hello.
      I had made a bot that clicks and doing stuff. It is working fine, but when i move it to another PC ImageSearch stop working. I captured same image of a button again and i observed that they are a little bit different. How to deal with this? I wonder if i will make black and white detection might work, or not ... i don't know. The point is i am not willing to re-do photos on each and every PC i move the scripts.
       
      ClickOnImageWithToleranceFast("images/fb_about.bmp",16) Func ClickOnImageWithToleranceFast($image_path,$tolerance) If SearchForImageOnScreenWithTolerance($image_path,$tolerance) Then If $x <> 0 And $y <> 0 Then MouseMove($x+5, $y+5,0) Sleep(500) MouseClick("left") Sleep(500) EndIf EndIf EndFunc  
      Link : https://postimg.org/gallery/z6n168ps/585debf1/#
      Also i have attached them.
      Thank you
      fb_about.bmp
      fb_about2.bmp
    • 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.