computergroove

ImageSearch is giving me an error message when I try to compile

3 posts in this topic

#1 ·  Posted (edited)

I am trying to integrate imagesearch into a script I am making. When I try to compile the script I get the following inside imagesearch.au3 under all 4 of the imagesearch.au3 defined functions:

"Error: Missing separator character before keyword"

I tried the beta version of Autoit and it is doing the same thing. I am using the x32 version of the imagesearch.au3 found here - https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwiUmsrEsLzPAhWs7YMKHS9MClQQFggfMAA&url=https%3A%2F%2Fwww.autoitscript.com%2Fforum%2Ftopic%2F148005-imagesearch-usage-explanation%2F&usg=AFQjCNFwpFnZMxVK9H4cDASRnjiB-65gOw&bvm=bv.134495766,d.amc

I have put the imagesearchDLL.dll in both the includes directory and the system32 directory. I am using x64 Windows 8.1 Pro. I cant see anything wrong. Please help.

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites



#2 ·  Posted

Hello. Check in function's  byref parameter. make sure you set a space after every comma.

 

Func _TestError(ByRef $a,ByRef $b)

EndFunc


Func _TestNoError(ByRef $a, ByRef $b)

EndFunc

 

Saludos

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

That worked. Here it is the imagesearch.au3 modified code that worked.

#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, $HBMP=0)
   return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance,$HBMP)
EndFunc

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

    ; 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, $HBMP=0)
    $waitSecs = $waitSecs * 1000
    $startTime=TimerInit()
    While TimerDiff($startTime) < $waitSecs
        sleep(100)
        $result=_ImageSearch($findImage,$resultPosition,$x, $y,$tolerance,$HBMP)
        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, $HBMP=0)
    $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,$HBMP)
            if $result > 0 Then
                return $i
            EndIf
        Next
    WEnd
    return 0
EndFunc

 

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

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

  • Similar Content

    • Miliardsto
      ImageSearch Dll not working on 32bit
      By Miliardsto
      Hello i got problem with ImageSearchDll.dll
      It works for me perfect always I made program which one use a lot of ImageSearch funcs on 64bit.
      I got 64bit and i copied to c:/Windows - ImageSearchDll.dll 64bit version
      But I encountered some friends got 32bit OS and then if I compile program for 32bit then they put ImageSearchDll.dll 32bit ver on windows dir and program crash when function is call.
      it happens always :/
       
      How to run this func on 32bit?
    • SaeidN
      ImageSearch and MouseDrag in background window
      By SaeidN
      Hi,
      I saw a couple topics about both mousedrag and imagesearch in background or minimized window, but none of them has the solution, and they were old topics.
      So I wanted to ask whether there is a way to mouse drag without the cursor to move, (I want to use mouse when mousedrag is working on a window). I don't know whether I can mix ControlMove with some other stuff or any other way?
      And also for the image search, is there any way to search for image (or pixel) in a background or minimized window? I thought maybe there is a au3 or dll or ... file for doing this.
      Another question I have: Any way to pinch zoom (two fingers) a window like "windows photo viewer" to zoom in or out? I saw something almost the same here, but not what I want.
      I appreciate it.
    • billshu
      _ImageSearch with $transparency
      By billshu
      Does anyone have experience with transparency on _ImageSearch?  The code attached finds the image "base.bmp" but at position 0,0 not near the center of the screen as it appears. My goal is to find the Big Blue "G" regardless of the background.  I have not yet found the base image, so I have not tested changing the background. Do you have to use image formats that support transparency?  If so, how would you capture the image from within autoit code and set the transparency color?
      Test1.au3
      ImageSearch.au3
      base.bmp
    • Reizvoller
      ImageSearch Script Closing w/ Error
      By Reizvoller
      Hello,
      I am back once again to ask for assistance. I am just trying to fool around with the "ImageSearch" function in order to detect when certain elements appear on my active window to then respond to. To begin testing this I simply cut out a small segment of my background, saved it as a BMP, and used that as the bmp for the search function. I had hoped for it to just run through quickly and say it found it and spit out the X Y coords of where it was found. Instead I am getting this : http://screencast.com/t/MD9aOzPhETE
      Here's my script thus far :
      #Include <msgBoxConstants.au3> #Include <ImageSearch.au3> global $x = 0 global $y = 0 CheckForImage () Func checkForImage () Local $Search = _ImageSearchArea ('ninjaCheck.bmp', 1, 0, 0, 1366, 768, $x, $y, 100) If $Search = 1 Then MsgBox ($IDOK,"Found",$resultPosition) EndIf EndFunc While 1 Sleep (10) WEnd What I would like assistance with is how do I "Debug" this in order to see where/why it is failing.
      I've reviewed https://www.autoitscript.com/wiki/FAQ#How_can_I_debug_my_script.3F but I am not entirely sure how to apply the information. If I could get a return on "Hey, this Func or This Line is where I died" , that would be awesome.
      Any suggestions on how I can tackle this issue?
      Thank you for your time!
      -Reiz
       
      checkNinja.bmp is " " around it now and it has the same result 
    • avidovi
      ImageSearch error
      By avidovi
      Hello friends,
      i need your help and advice regarding the image search function.
      I need to click an image on a web site. after using the image search function i am getting the following error, on the image search function
      if $result[0]="0" then return 0 if $result^ ERROR I am using the x64 configuration with the following files attached
      thanks for helping..
      ImageSearch 64 bit.rar