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

@Bert you look to be correct :>

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


√-1 2^3 ∑ π, and it was delicious!

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.


√-1 2^3 ∑ π, and it was delicious!

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

    • DeathChicken
      By DeathChicken
      If possible please add or edit the comments to explain how this works.
       
      ;includes functions from other things
      #include <GDIPlus.au3>
      #include <ScreenCapture.au3>
      ;hotkeys
      HotKeySet("{ESC}", _exit)
      HotKeySet("{F1}", _scan)
      ;global variables
      Global $win_title                    ;name of the window
      Global $area_x                        ;
      Global $area_y                        ;
      Global $area_w                       ;
      Global $area_h                        ;
      Global $cursor                         ;
      Global $rect_file                      ;
      Global $hbmpscreen              ;
      Global $i=  1043                      ;moves the rect
      Global $ii=    378                      ;moves the rect
      Global $x=1044                        ;inner rect offset
      Global $y=501                          ;inner rect offset
      Global $hbmprect                    ;image inside rect
      Global $hscreen                        ;image whole screen
                                         
      _GDIPlus_Startup()                    ;?
      ;display hotkeys on screen
      ToolTip("Press F1 to scan | Press ESC to Exit",0,0)
                                          ;infinite loop to keep prog running
      While 1
          Sleep(100)
      WEnd
      Func _scan()
      ;~ reads your screen area:
      _read()
      ;~ converts screen captured into bmp
      _convert()
      ;~ .  Loads converted bmp to be read
      _loadBMP()
      ;~ compares the bmp of your scanned screen to the actual screen that is being displayed
      _compare()
      EndFunc
                                          ;reads screen
      Func _read()
          $hscreen = _ScreenCapture_CaptureWnd("", WinGetHandle($win_title), $area_x, $area_y, $area_x + $area_w, $area_y + $area_h, $cursor)
      EndFunc
                                          ;converts screen into bmp
      Func _convert()
          _GDIPlus_BitmapCreateFromHBITMAP($hscreen)
      EndFunc
                                          ;loads converted screen
      Func _loadBMP()
      _GDIPlus_BitmapCreateFromFile($rect_file)
      EndFunc
                                          ;compares savedBMP to current screen
      Func _compare()
      ;If(                              below code                                     ) = (                   below code           ) Then
      If _GDIPlus_BitmapGetPixel($hbmpscreen, ($i + $x) - $area_x, ($ii + $y) - $area_y) = _GDIPlus_BitmapGetPixel($hbmprect, $x, $y) Then
      ;display message box titled found with a message of found
      MsgBox("","","found")
      ;if above is not correct then
      EndIf
      EndFunc
                                          ;exit func
      Func _exit()
          Exit
      EndFunc
    • magmet00
      By magmet00
      Do you have a working imagesearch.au3 with working dll?
      and how can i gethandle and send keyboard/mouse commands to hidden d3d window?
       
      i have tried imagesearch2015 but im getting dll error every time and tried older imagesearchs too in forum what i found.
      i have tried many things to send commands to hidden/background d3dwindow still nothing works.
      Can you help me please?
       
    • 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?