Jump to content
npenfold

If, Then Click, Find, Repeat

Recommended Posts

npenfold

Hello AutoIt Community,

I want to create a script and I'd like to ask for some help. Here's what I'd like it to do:

1. Search for an image then click on it.

2. Wait for 1 of 7 images to appear and click on whichever one it is out of the 7.

3. Repeat the whole process

Here's the code I have so far:

Quote

#include <ImageSearch.au3>

$x1=0
$y1=0

$result = _ImageSearch("find1.bmp",0,$x1,$y1,0)
if $result=1 Then
    MouseMove($x1,$y1,3)
    MouseClick("Left")
EndIf

Dim $anArray[10]
$anArray[0]=7  ; 7 images to wait to appear
$anArray[1]="x1.bmp"  ; image 1 to wait for
$anArray[2]="x2.bmp"  ; image 2 to wait for
$anArray[2]="x3.bmp"  ; image 3 to wait for
$anArray[2]="x4.bmp"  ; image 4 to wait for
$anArray[2]="x5.bmp"  ; image 5 to wait for
$anArray[2]="x6.bmp"  ; image 6 to wait for
$result = _WaitForImagesSearch($anArray,15,1,$x1,$y1,0)
if $result=1 Then
    MouseMove($x1,$y1,3)
    MouseClick("Left")
EndIf
if $result=2 Then
    MouseMove($x1,$y1,3)
    MouseClick("Left")
 EndIf
 if $result=3 Then
    MouseMove($x1,$y1,3)
    MouseClick("Left")
 EndIf
 if $result=4 Then
    MouseMove($x1,$y1,3)
    MouseClick("Left")
 EndIf
 if $result=5 Then
    MouseMove($x1,$y1,3)
    MouseClick("Left")
 EndIf
 if $result=6 Then
    MouseMove($x1,$y1,3)
    MouseClick("Left")
EndIf
if $result=0 Then
    MouseMove($x1,$y1,3)
    MouseClick("Left")
EndIf

Thank you in advance for your help.

Share this post


Link to post
Share on other sites
JLogan3o13

@npenfold what kind of images are you searching for, or what kind of application (desktop, web, game, etc.). The application will often determine how you go about it.


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

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.