Jump to content
exoticsquids

Multiple image searching solution to my issue/little guidance?

Recommended Posts

exoticsquids

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
exoticsquids

I don't know if there is a edit button but the mouseclick in the idea porgramming the last one those $x1, $y1 is meant to be 2 not 1. 

Share this post


Link to post
Share on other sites
water

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-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - 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
exoticsquids

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
exoticsquids

The app just lets you watch ad's the whole time. I am setting it up to run automatically basically. if that makes more sense xD I re-read the top.

Share this post


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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Jos

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
exoticsquids

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
Jos
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 


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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

×