privatemonkey

AutoIt multiple Image searches

7 posts in this topic

English:

Spoiler

Hello dear IT member i have a few question beecause i cant seem to get it working:

so i wrote a code with imagesearch and its searching perfect if its one by one but im trying to put the code together into 1 so its searching for all the pictures i hope you can help me

 

code #1
#include <ImageSearch2015.au3>
HotKeySet("{-}", "Terminate")
While 1

$x1=0
$y1=0

$picture = "C:\Users\Daniel\Desktop\ImageSearch2015\u.png"
Do
$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)

ConsoleWrite($result)
until $result =1 ;
if $result=1 Then

        Send("{U down}") ; Holds the A key down
        Send("{U up}") ; Releases the A key
Else
        MsgBox(0,"MSG","End")


EndIf

WEnd


Func Terminate()
    Exit 0
EndFunc
------------------------------------------------------------
Code #2
#include <ImageSearch2015.au3>
HotKeySet("{-}", "Terminate")
While 1

$x1=0
$y1=0

$picture = "C:\Users\Daniel\Desktop\ImageSearch2015\H.png"
Do
$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)

ConsoleWrite($result)
until $result =1 ;
if $result=1 Then

        Send("{H down}") ; Holds the A key down
        Send("{H up}") ; Releases the A key
Else
        MsgBox(0,"MSG","End")


EndIf

WEnd




Func Terminate()
    Exit 0
EndFunc
-----------------------------------------
code #3
#include <ImageSearch2015.au3>
HotKeySet("{-}", "Terminate")
While 1

$x1=0
$y1=0

$picture = "C:\Users\Daniel\Desktop\ImageSearch2015\z.png"
Do
$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)

ConsoleWrite($result)
until $result =1 ;
if $result=1 Then

        Send("{Z down}") ; Holds the A key down
        Send("{Z up}") ; Releases the A key
Else
        MsgBox(0,"MSG","End")


EndIf

WEnd

Func Terminate()
    Exit 0
EndFunc


----------------
code #4
#include <ImageSearch2015.au3>
HotKeySet("{-}", "Terminate")
While 1

$x1=0
$y1=0

$picture = "C:\Users\Daniel\Desktop\ImageSearch2015\J.png"
Do
$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)

ConsoleWrite($result)
until $result =1 ;
if $result=1 Then

        Send("{J down}") ; Holds the A key down
        Send("{J up}") ; Releases the A key
Else
        MsgBox(0,"MSG","End")


EndIf

WEnd


Func Terminate()
    Exit 0
EndFunc



------------------

Ok so this are my 4 codes (4 files) and i want to put it togehter to 1 piece so its searching for all those 4 codes / pictures in 1 code / at a time hope you can help me out!

 

greetings

 

privatemonkey:)

German:

Spoiler

Hallo liebe Auto IT member Ich habe ein paar Fragen.also ich habe einen Code geschrieben mit imagesearch und es sucht perfekt wenn es ein einzelner code ist (nur eine file) aber da man nicht 4 files aufeinmal laufen lassen kann muss ich die 4 codes/files zu einer hinzufügen und ich kriege das nicht hin ich hoffe ihr könnt mir helfen ,dass er dann nach 4 Bildern sucht und jeweils den input zu dem passenden bild macht... Hoffe ihr könnt mir helfen :)

code #1
#include <ImageSearch2015.au3>
HotKeySet("{-}", "Terminate")
While 1

$x1=0
$y1=0

$picture = "C:\Users\Daniel\Desktop\ImageSearch2015\u.png"
Do
$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)

ConsoleWrite($result)
until $result =1 ;
if $result=1 Then

        Send("{U down}") ; Holds the A key down
        Send("{U up}") ; Releases the A key
Else
        MsgBox(0,"MSG","End")


EndIf

WEnd


Func Terminate()
    Exit 0
EndFunc
------------------------------------------------------------
Code #2
#include <ImageSearch2015.au3>
HotKeySet("{-}", "Terminate")
While 1

$x1=0
$y1=0

$picture = "C:\Users\Daniel\Desktop\ImageSearch2015\H.png"
Do
$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)

ConsoleWrite($result)
until $result =1 ;
if $result=1 Then

        Send("{H down}") ; Holds the A key down
        Send("{H up}") ; Releases the A key
Else
        MsgBox(0,"MSG","End")


EndIf

WEnd




Func Terminate()
    Exit 0
EndFunc
-----------------------------------------
code #3
#include <ImageSearch2015.au3>
HotKeySet("{-}", "Terminate")
While 1

$x1=0
$y1=0

$picture = "C:\Users\Daniel\Desktop\ImageSearch2015\z.png"
Do
$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)

ConsoleWrite($result)
until $result =1 ;
if $result=1 Then

        Send("{Z down}") ; Holds the A key down
        Send("{Z up}") ; Releases the A key
Else
        MsgBox(0,"MSG","End")


EndIf

WEnd

Func Terminate()
    Exit 0
EndFunc


----------------
code #4
#include <ImageSearch2015.au3>
HotKeySet("{-}", "Terminate")
While 1

$x1=0
$y1=0

$picture = "C:\Users\Daniel\Desktop\ImageSearch2015\J.png"
Do
$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)

ConsoleWrite($result)
until $result =1 ;
if $result=1 Then

        Send("{J down}") ; Holds the A key down
        Send("{J up}") ; Releases the A key
Else
        MsgBox(0,"MSG","End")


EndIf

WEnd


Func Terminate()
    Exit 0
EndFunc



------------------

So das war der code bzw die 4 codes/files ich hoffe ihr könnt mir damit helfen

 

MfG

 

privatemonkey :)

^ spoiler

Share this post


Link to post
Share on other sites



and yea BTW  if i make it intro one code it will only use the first "picture" but not the other 3 :( please help...

Share this post


Link to post
Share on other sites

This is how it lookks like if i put it into one code 

But that doesnt work it only reacts to the first picture "u.png" not to the others :( hope you can help me ^_^

 

#include <ImageSearch2015.au3>

HotKeySet("{-}", "Terminate")
While 1

$x1 = 1
$y1 = 1

$picture = "C:\Users\Daniel\Desktop\ImageSearch2015\u.png"
Do
$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)
ConsoleWrite($result)
until $result =1 ;
if  $result = 1 Then

        Send("{U down}") ; Holds the A key down
        Send("{U up}") ; Releases the A key

ElseIf $picture = "C:\Users\Daniel\Desktop\ImageSearch2015\H.png" Then

Do
$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)
ConsoleWrite($result)
until $result =1 ;
if $result=1 Then

        Send("{H down}") ; Holds the A key down
        Send("{H up}") ; Releases the A key
ElseIf  $picture = "C:\Users\Daniel\Desktop\ImageSearch2015\z.png" Then
Do
$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)

ConsoleWrite($result)
until $result =1 ;
if $result=1 Then

        Send("{Z down}") ; Holds the A key down
        Send("{Z up}") ; Releases the A key
ElseIf  $picture = "C:\Users\Daniel\Desktop\ImageSearch2015\J.png" Then


Do
$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)

ConsoleWrite($result)
until $result =1 ;
if $result=1 Then

        Send("{J down}") ; Holds the A key down
        Send("{J up}") ; Releases the A key

EndIf
EndIf
EndIf
EndIf


WEnd

Func Terminate()
    Exit 0
EndFunc

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Local $Picture = "A"                ; Test Value A,B,C

Do
    If $Picture = "A" Then          ; First find.
        WhichPictureISelected ( )
        $Picture = "B"              ; gets us further to 'B'
    ElseIf $Picture = "B" Then
        WhichPictureISelected ( )
        $Picture = "stop"
    ElseIf $Picture = "C" Then
        WhichPictureISelected ( )
        ; ...
        ; ...
    EndIf
Until $Picture = "stop"

Func WhichPictureISelected ( )
    MsgBox ( 0, "Found", "picture = " & $Picture )
EndFunc

First problem i see is that in your code the value $picture is set to u.png but where does the variable $picture get changed another value? See my example code. It can Find A, B but will never find C for obvious reasons.

Edited by pluto41

Share this post


Link to post
Share on other sites
On 6.9.2016 at 6:25 PM, pluto41 said:
Local $Picture = "A"                ; Test Value A,B,C

Do
    If $Picture = "A" Then          ; First find.
        WhichPictureISelected ( )
        $Picture = "B"              ; gets us further to 'B'
    ElseIf $Picture = "B" Then
        WhichPictureISelected ( )
        $Picture = "stop"
    ElseIf $Picture = "C" Then
        WhichPictureISelected ( )
        ; ...
        ; ...
    EndIf
Until $Picture = "stop"

Func WhichPictureISelected ( )
    MsgBox ( 0, "Found", "picture = " & $Picture )
EndFunc

First problem i see is that in your code the value $picture is set to u.png but where does the variable $picture get changed another value? See my example code. It can Find A, B but will never find C for obvious reasons.

hey sorry for the late answer :) but where did the until $result = 1 go im confused in this code :3 can you explain me further please?  or help me fixing the code together ,thanks :3

 

greetings

 

Monkey

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

What about something like this, instead?

#include <ImageSearch2015.au3>

HotKeySet("{-}", "Terminate")
While 1

    While _ImageSearch("C:\USers\Daniel\Desktop\ImageSearch2015\u.png" = 1
        Send("{U down}")
        Send("{U up}")
    WEnd

    While _ImageSearch("C:\USers\Daniel\Desktop\ImageSearch2015\H.png" = 1
        Send("{H down}")
        Send("{H up}")
    WEnd

    While _ImageSearch("C:\USers\Daniel\Desktop\ImageSearch2015\z.png" = 1
        Send("{Z down}")
        Send("{Z up}")
    WEnd

    While _ImageSearch("C:\USers\Daniel\Desktop\ImageSearch2015\J.png" = 1
        Send("{J down}")
        Send("{J up}")
    WEnd
WEnd

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

 

Edited by Sori

If you need help with your stuff, feel free to get me on my Skype.

I often get bored and enjoy helping with projects.

Share this post


Link to post
Share on other sites
15 minutes ago, Sori said:

What about something like this, instead?

#include <ImageSearch2015.au3>

HotKeySet("{-}", "Terminate")
While 1

    While _ImageSearch("C:\USers\Daniel\Desktop\ImageSearch2015\u.png" = 1
        Send("{U down}")
        Send("{U up}")
    WEnd

    While _ImageSearch("C:\USers\Daniel\Desktop\ImageSearch2015\H.png" = 1
        Send("{H down}")
        Send("{H up}")
    WEnd

    While _ImageSearch("C:\USers\Daniel\Desktop\ImageSearch2015\z.png" = 1
        Send("{Z down}")
        Send("{Z up}")
    WEnd

    While _ImageSearch("C:\USers\Daniel\Desktop\ImageSearch2015\J.png" = 1
        Send("{J down}")
        Send("{J up}")
    WEnd
WEnd

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

 

dunno i'd need to try that :) 'll reply after i tried

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