Jump to content

Multiple image searching solution to my issue/little guidance?


Recommended Posts

Hello AutoIt Community!

 

This is my very first post!! I have been using Auto if for small things like moving mouse and clicking things. I am not a compete newbie with programming but I am getting into a little more advance stuff now and was wondering if/what is the best solution. I am wanting to make a small bot that basically Clicks on image1.png to start the program. Almost all the time there is a advertisement so I am going to snip every x button (image2 through however many there are) and want the bot to search for which x comes up first then once clicked it goes back to the app/image1 to where it repeats itself. So I am looking for a loop inside of a loop! Can you do things like that? or would it be best to maybe do if statement then else and if its not there just move to the next if till one fits the box?

 

p.s. I am about to head to work so might be a few hours before I respond back to the post.

 

Thanks for the help in advance!

ExoticSquids

 

 

What I have:

#include <ImageSearch2015.au3>

HotKeySet("1", ForceExit)

$x1=0
$y1=0

Func Loop()
    While 1
        WinActivate("MyprogramHere")

    $image1 = "C:\Users\gunth_000\Desktop\Scripts\pictures\image1.png"
    $result = _ImageSearch($image1, 1, $x1, $y1, 0, 0)
        If $result=1 Then
            Mouseclick("left",$x1,$y1,1,10)
        EndIf
    WEnd
EndFunc

 

What I was thinking:

#include <ImageSearch2015.au3>

HotKeySet("1", ForceExit)

$x1=0
$y1=0

$x2=0

$y2=0

Func Loop()
    While 1
    ;---Image1 is the app---
    $image1 = "C:\Users\gunth_000\Desktop\Scripts\pictures\image1.png"
    $result = _ImageSearch($image1, 1, $x1, $y1, 0, 0)
        If $result=1 Then
            Mouseclick("left",$x1,$y1,1,10)
        Else
    ;---Image2 is the x button (Close button on advertisement)-----
    $image2 = "C:\Users\gunth_000\Desktop\Scripts\pictures\image2.png"
    $result2 = _ImageSearch($image2, 1, $x2, $y2, 0, 0)
            $result2=1 Then
            MouseClick("left",$x1,$y1,1,10)
        Else..... ;-----so on from here------
        EndIf
    WEnd
EndFunc

Link to comment
Share on other sites

Welcome to AutoIt and the forum!

Which program do you try to automate? Most of the time there are more reliable ways to do what you want to do without using picturesearch. 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Well I am using NoxPlayer. I am going to be clicking basically the play button (image1) the video/ad will pop up and I need to turn the ad off so that is why I am just snipping all the x buttons (image2-whatever). I have ran it with send("{ESC}") it works on almost all of them I run into some that I can't just click esc to get out. The other thing I am running into that way is timing, because of loading time its very small but builds up over time. The Esc would work with a little extra work for tweaking but I think I would still need a if statements for the ones that don't work with esc being pressed. 

Link to comment
Share on other sites

  • Developers
3 hours ago, exoticsquids said:

The app just lets you watch ad's the whole time

Sounds like fun... (not really) 
Just wondering why one would want this?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

2 minutes ago, Jos said:

Just wondering why one would want this?

Because people get paid for it.

Link to comment
Share on other sites

  • Developers
14 minutes ago, RTFC said:

Because people get paid for it.

I know but guess I wanted the OP to state that. ;)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

No worries ... just wanted to let you know I might be old but still have the brains going at a proper speed. (I am sure some particular individual will chime in now soon) :)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers
1 hour ago, exoticsquids said:

Never mind I figured it Thanks overall though. 

@exoticsquids,  Actually I do mind and would like to hear what you are doing with this script...  guess the post kinda explained why.

Jos 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...