Jump to content
exoticsquids

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

Share this post


Link to post
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 (2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-03-02 - Version 1.3.5.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
2 minutes ago, Jos said:

Just wondering why one would want this?

Because people get paid for it.

Share this post


Link to post
Share on other sites
14 minutes ago, RTFC said:

Because people get paid for it.

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Never mind I figured it Thanks overall though. 

I am just doing Switch case statements. Thanks anyways. I learn very quick when it comes to programming. 

 

CLOSED Figured it out

Share this post


Link to post
Share on other sites
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 

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

×
×
  • Create New...