Bou

Imagesearch problem

12 posts in this topic

Helllo guys

I have tried to search the forums before posting but nothing solved my problem :(

I included the "imagesearch.au3" and its DLL today and i tried to run it, but i have faced couple of problems, i have tried to install 32x version 64x ... i have tried the old searchimage dll and au3, and the new ones, but nothing solves the problem, not even running it as an admin, installing SciTE4 all over again... :(

 

Could you guys please help me ? 

Thanks in advance.

 

Untitled.png

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

i have attached my script and the ImageSearch.au3 that i have downloaded

<snip>

 

 

 

Edited by Melba23
Removed images

Share this post


Link to post
Share on other sites

Bou,

Welcome to the AutoIt forums.

Posting images of your code is not a great help, much better to use Code tags - see here how to do it.

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Okay, sorry didnt know... here's my code:

#include <imagesearch.au3>

HotKeySet('=', 'start')
$x = 0
$y = 0

Func Start()
    $search = _ImageSearch('capture.bmp', 0, $x, $y, 0)
    If $search = 1 Then
        MouseMove($x, $y, 10)
    EndIf
EndFunc   ;==>Start

While 1
    Sleep(100)
WEnd

and here's the ImageSearch.au3's code:

#include-once
; ------------------------------------------------------------------------------
;
; AutoIt Version: 3.0
; Language:       English
; Description:    Functions that assist with Image Search
;                 Require that the ImageSearchDLL.dll be loadable
;
; ------------------------------------------------------------------------------

;===============================================================================
;
; Description:      Find the position of an image on the desktop
; Syntax:           _ImageSearchArea, _ImageSearch
; Parameter(s):     
;                   $findImage - the image to locate on the desktop
;                   $tolerance - 0 for no tolerance (0-255). Needed when colors of 
;                                image differ from desktop. e.g GIF
;                   $resultPosition - Set where the returned x,y location of the image is.
;                                     1 for centre of image, 0 for top left of image
;                   $x $y - Return the x and y location of the image
;
; Return Value(s):  On Success - Returns 1
;                   On Failure - Returns 0 
;
; Note: Use _ImageSearch to search the entire desktop, _ImageSearchArea to specify
;       a desktop region to search
;
;===============================================================================
Func _ImageSearch($findImage,$resultPosition,ByRef $x, ByRef $y,$tolerance)
   return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance)
EndFunc

Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance)
    ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
    if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage
    $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)

    ; If error exit
    if $result[0]="0" then return 0
    
    ; Otherwise get the x,y location of the match and the size of the image to
    ; compute the centre of search
    $array = StringSplit($result[0],"|")
   
   $x=Int(Number($array[2]))
   $y=Int(Number($array[3]))
   if $resultPosition=1 then
      $x=$x + Int(Number($array[4])/2)
      $y=$y + Int(Number($array[5])/2)
   endif
   return 1
EndFunc

;===============================================================================
;
; Description:      Wait for a specified number of seconds for an image to appear
;     
; Syntax:           _WaitForImageSearch, _WaitForImagesSearch
; Parameter(s):     
;                   $waitSecs  - seconds to try and find the image
;                   $findImage - the image to locate on the desktop
;                   $tolerance - 0 for no tolerance (0-255). Needed when colors of 
;                                image differ from desktop. e.g GIF
;                   $resultPosition - Set where the returned x,y location of the image is.
;                                     1 for centre of image, 0 for top left of image
;                   $x $y - Return the x and y location of the image
;
; Return Value(s):  On Success - Returns 1
;                   On Failure - Returns 0 
;
;
;===============================================================================
Func _WaitForImageSearch($findImage,$waitSecs,$resultPosition,ByRef $x, ByRef $y,$tolerance)
    $waitSecs = $waitSecs * 1000
    $startTime=TimerInit()
    While TimerDiff($startTime) < $waitSecs
        sleep(100)
        $result=_ImageSearch($findImage,$resultPosition,$x, $y,$tolerance)
        if $result > 0 Then
            return 1
        EndIf
    WEnd
    return 0
EndFunc

;===============================================================================
;
; Description:      Wait for a specified number of seconds for any of a set of
;                   images to appear
;     
; Syntax:           _WaitForImagesSearch
; Parameter(s):     
;                   $waitSecs  - seconds to try and find the image
;                   $findImage - the ARRAY of images to locate on the desktop
;                              - ARRAY[0] is set to the number of images to loop through
;                                ARRAY[1] is the first image
;                   $tolerance - 0 for no tolerance (0-255). Needed when colors of 
;                                image differ from desktop. e.g GIF
;                   $resultPosition - Set where the returned x,y location of the image is.
;                                     1 for centre of image, 0 for top left of image
;                   $x $y - Return the x and y location of the image
;
; Return Value(s):  On Success - Returns the index of the successful find
;                   On Failure - Returns 0 
;
;
;===============================================================================
Func _WaitForImagesSearch($findImage,$waitSecs,$resultPosition,ByRef $x, ByRef $y,$tolerance)
    $waitSecs = $waitSecs * 1000
    $startTime=TimerInit()
    While TimerDiff($startTime) < $waitSecs
        for $i = 1 to $findImage[0]
            sleep(100)
            $result=_ImageSearch($findImage[$i],$resultPosition,$x, $y,$tolerance)
            if $result > 0 Then
                return $i
            EndIf
        Next    
    WEnd
    return 0
EndFunc

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Do you work with a 64bit windows?

Maybe you have to add "#AutoIt3Wrapper_UseX64 = Y" on the top of your script.

#AutoIt3Wrapper_UseX64 = Y

#include <imagesearch.au3>

HotKeySet('=', 'start')
$x = 0
$y = 0

Func Start()
    $search = _ImageSearch('capture.bmp', 0, $x, $y, 0)
    If $search = 1 Then
        MouseMove($x, $y, 10)
    EndIf
EndFunc   ;==>Start

While 1
    Sleep(100)
WEnd

 

Edited by nobbitry
1 person likes this

Share this post


Link to post
Share on other sites

This has been asked a lot, a lot of posts in the imagesearch thread, and hundreds of posts on other forums.

If (IsArray($result) = False) Then Return 0

Just check to see if it is an array

1 person likes this

Share this post


Link to post
Share on other sites
8 minutes ago, InunoTaishou said:

This has been asked a lot, a lot of posts in the imagesearch thread, and hundreds of posts on other forums.

If (IsArray($result) = False) Then Return 0

Just check to see if it is an array

 

 

Thank you so much. its working now. but only when i "right click" Run script (86x), anyway to make it work with 64x :D?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Use the proper x64 ImageSearchDLL.dll and you'll have to set your Scite to use the x64 compiler to run scripts and compile scripts if you want to use x64  (I don't remember where this setting is in Scite)

Edited by InunoTaishou
1 person likes this

Share this post


Link to post
Share on other sites

Also there seems to be a problem in the SearchImage code, if my code doesnt find the picture looking for

The error:

"C:\Program Files (x86)\AutoIt3\Include\ImageSearch.au3" (46) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$x = IsArray(Int(Number($array[2])))
$x = IsArray(Int(Number(^ ERROR

The original part of the code that has the problem:

; Otherwise get the x,y location of the match and the size of the image to
    ; compute the centre of search
    $array = StringSplit($result[0], "|")

    $x = Int(Number($array[2]))
    $y = Int(Number($array[3]))
    If $resultPosition = 1 Then
        $x = $x + Int(Number($array[4]) / 2)
        $y = $y + Int(Number($array[5]) / 2)
    EndIf
    Return 1
EndFunc   ;==>_ImageSearchArea

 

Share this post


Link to post
Share on other sites

I dont think that my answer would help to fix the problem... but whatever... i want to use it to automate games i play

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

You're right, it doesn't help - sounds like you've already seen the forum rules and know this is a topic that is not open for discussion.

If you haven't, you need to read them before you post again - especially the part about game automation.

Edited by JLogan3o13

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