aa2zz6

How would I make the image search search only inside my GUI?

6 posts in this topic

How would I make the image search search only in my GUI? The GUI class name: AutoIt v3 GUI.

#include <ImageSearch.au3>
#include <GDIPlus.au3>

test()

Func test()

    #include <ImageSearch.au3>
    Local $aIcons[1], $i

    $aIcons[0] = @ScriptDir & "\pics\image1.png"

    $x = 0
    $y = 0

    For $i = 0 To UBound($aIcons) - 1
        $result = _ImageSearch($aIcons[$i], 1, $x, $y, 20, 0)
        If $result > 0 Then
            MouseClick($MOUSE_CLICK_PRIMARY, $x, $y, 1)
            ExitLoop
            Sleep(1000)
        EndIf
    Next

EndFunc   ;==>test

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <ImageSearch.au3>
#include <GDIPlus.au3>

test()

Func test()

    #include <ImageSearch.au3>
    Local $aIcons[1], $i, $x, $y

    $aIcons[0] = @ScriptDir & "\pics\image1.png"



    For $i = 0 To UBound($aIcons) - 1
        $p = WinGetPos("AutoIt v3 GUI")
        $result = _ImageSearchArea($aIcons[$i],1,$p[0],$p[1],$p[0]+$p[2],$p[1]+$p[3], $x, $y, 20)
        If $result > 0 Then
            MouseClick($MOUSE_CLICK_PRIMARY, $x, $y, 1)
            ExitLoop
            Sleep(1000)
        EndIf
    Next

EndFunc   ;==>test

 

Edited by Tyzing

Share this post


Link to post
Share on other sites

I tried using the Local $aPos WinGetPos("classname=AutoIt v3 GUI") but the script didn't search inside the GUI, but rather it's still searching outside the GUI. 

Share this post


Link to post
Share on other sites
#include <ImageSearch.au3>
#include <GDIPlus.au3>

test()

Func test()

    #include <ImageSearch.au3>
    Local $aIcons[1], $i, $x, $y

    $aIcons[0] = @ScriptDir & "\pics\image1.png"



    For $i = 0 To UBound($aIcons) - 1
        $p = WinGetPos("[CLASS:AutoIt v3 GUI]")
        $result = _ImageSearchArea($aIcons[$i],1,$p[0],$p[1],$p[0]+$p[2],$p[1]+$p[3], $x, $y, 20)
        If $result > 0 Then
            MouseClick($MOUSE_CLICK_PRIMARY, $x, $y, 1)
            ExitLoop
            Sleep(1000)
        EndIf
    Next

EndFunc   ;==>test

Use this

Share this post


Link to post
Share on other sites

The process is unable to search only inside the GUI. I tried it a few different examples from the Help file but it didn't work.

Share this post


Link to post
Share on other sites

ImageSearch searches in the whole DeskTop, but have you ever looked in the Imagesearch.au3?

ImageSearchArea is what you're looking for, it's the working function called by Imagesearch with Params for the whole Desktop.

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