Jump to content

If, Then Click, Find, Repeat


 Share

Recommended Posts

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.

Link to comment
Share on other sites

  • Moderators

@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.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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