Jump to content

_ImageSearch Unknown function name


Recommended Posts

I downloaded: https://www.autoitscript.com/forum/files/file/471-image-search-udf/

I have also added #include "_ImageSearch.au3" and "_ImageSearchDebug.au3" to my script.

My script its in the same folder of _ImageSearcha.au3,_ImageSearchDebug.au3 (with dll files etc.)

Every time I try to run my script I get: Line48 Error: Unknown function name.

While(_ImageSearch(Seach_1.bmp, 0) And _ImageSearch(Seach_2.bmp, 0) <> True)
   Sleep(100)
WEnd ;Sleep until you see this 2 image
If(_ImageSearch(Seach_1.bmp, 0) And _ImageSearch(Seach_2.bmp, 0) = True)Then

 

Edited by Zag8888
Link to post
Share on other sites
  • Developers

Where is your #include<> statement to add the imagesearch UDF's?

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

well your code is badly formatted...replace loop with :

Local $pos1, $pos2
While True
  $pos1 = _ImageSearch("Seach_1.bmp")
  if not $pos1[0] then ContinueLoop
  $pos2 = _ImageSearch("Seach_2.bmp")
  if $pos2[0] then ExitLoop
  Sleep(100)
WEnd ;Sleep until you see this 2 image

Your bmp where not included in quotes, and return value is an array.   Please read carfully the headers of the functions.

I just realized that the "no match" is not an @error but 0 in array[0]

Edited by Nine
Link to post
Share on other sites
  • Developers

No idea what you are asking me, but the posted code does not contain an #include<>.

As to the syntax of #include, I refer you to the helpfile.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
20 minutes ago, Nine said:

well your code is badly formatted...replace loop with :

Local $pos1, $pos2
While True
  $pos1 = _ImageSearch("Seach_1.bmp")
  if @error then ContinueLoop
  $pos2 = _ImageSearch("Seach_2.bmp")
  if not @error then ExitLoop
  Sleep(100)
WEnd ;Sleep until you see this 2 image

Your bmp where not included in quotes, and return value is an array.   Please read carfully the headers of the functions.

Hey, thanks for your help, I tried this code but it didn't worked for me

Link to post
Share on other sites
12 minutes ago, Nine said:

that's a bad character coming from the copy/paste, just delete it...

Not working, full code

While True
                  if not $pos1[0] then ContinueLoop
                     if $pos2[0] then ExitLoop
                        Sleep(100)
               WEnd
               If($pos1[0] And $pos2[0] = 1) Then
                  Sleep(2000)
                  MouseClick("left", 436 , 745 )
                  Sleep(5000)

Endif

 

THe code works with 0 errors, but the image its not found I guess

Edited by Zag8888
Link to post
Share on other sites
  • Developers
3 minutes ago, Zag8888 said:

Not working, full code

While True
                  if not $pos1[0] then ContinueLoop
                     if $pos2[0] then ExitLoop
                        Sleep(100)
               WEnd
               If($pos1[0] And $pos2[0] = 1) Then
                  Sleep(2000)
                  MouseClick("left", 436 , 745 )
                  Sleep(5000)

Endif

 

THe code works with 0 errors, but the image its not found I guess

Where in that code are you check for the image match?
What about you stop feeding us bits and pieces and post the full test code?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
2 hours ago, Jos said:

Where in that code are you check for the image match? Yes
What about you stop feeding us bits and pieces and post the full test code? Other code is useless and also is working perfectly...

Jos

Edit, thanks for all your help guys, I have finally fix it, I added 5 tolerance instead of 0 and now it works great

Edited by Zag8888
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By VIP
      Use MouseClick()  need:
      #RequireAdmin  
      Dll is already integrated in UDF !
      ; #INDEX# =============================================================== ; Title .........: ImageSearch ; AutoIt Version : 3.x ; Language ......: English ; Description ...: Check image Appears or Not and Return the position of an image on the desktop ; Author(s) .....: Dao Van Trong - TRONG.LIVE ; ======================================================================= ; #CURRENT# ============================================================= ; _ImageSearch ; _ImageSearch_Area ; _ImageSearch_Wait ; _ImageSearch_WaitArea ; ======================================================================== ;========================================================================= ; ; Author:...........: AutoIT VietNam : Dao Van Trong - TRONG.LIVE ; Description:......: Check image Appears or Not ; Find and return the position of an image on the desktop ; Syntax:........... _ImageSearch_Area, _ImageSearch ; Parameter(s):..... $_ImagePath: The image to locate on the desktop ; May be a list of image by delimited by "|" ; i.e: $_ImagePath = "image1.bmp|image2.bmp|image3.bmp" ; $P_x1 $P_y1: Position of 1st point ; $P_x2 $P_y2: Position of 2nd point - Default is last botton right of desktop ; $_Tolerance: 0 for no tolerance (0-255). Needed when colors of image differ from desktop. e.g GIF ; $_CenterPos: boolen. True will return $array[1] x $array[2] is center of image found. ; False will return top-left position ; Return Value(s):.. Return an array has 3 item ; On Success: $array[0] 1 ; On Failure: $array[0] 0 ; DLL not found or other error: $array[0] -1 ; $array[1] x $array[2]: position of image what found on desktop ; ; Note:............. Use _ImageSearch to search the entire desktop ; _ImageSearch_Area to specify a desktop region to search ; $_ImagePath with more item need more time appear on screen before function can detect. ; Decrease sleep time in the loop to detect faster. But less performance. I.e CPULoad increased ; ;======================================================================== EG 1:
      ;~ Opt("MustDeclareVars", 1) ;~ #AutoIt3Wrapper_UseX64=y ;~ #AutoIt3Wrapper_Change2CUI=y #RequireAdmin #include "_ImageSearch_UDF.au3" HotKeySet("{Esc}", "_Exit") ; Press ESC for exit Func _Exit() Exit 0 EndFunc ;==>_Exit Global Const $Ask_On_Found = 0 Global Const $Mouse_Move_On_Found = 1 Global Const $Mouse_Click_On_Found = 0 Global Const $iSleep_Time=500 Global $sCount = 0, $_Image_1 = @ScriptDir & "\example.bmp" ; First, use this function to create a file bmp, maybe a desktop icon for example') MsgBox(64 + 262144, 'ImageSearch', 'At first, create a file bmp,' & @CRLF & 'photos that will search on the screen!') _ImageSearch_Create_BMP($_Image_1) ConsoleWrite("! Search for images: " & $_Image_1 & @CRLF & '! Searching on the screen ...' & @CRLF) While 1 ToolTip('(Press ESC for EXIT) Searching ...', 1, 1) Sleep($iSleep_Time) $sCount += 1 Local $return = _ImageSearch($_Image_1) If $return[0] = 1 Then ConsoleWrite('- [' & $sCount & '] Image found:' & " X=" & $return[1] & " Y=" & $return[2] & @CRLF) If $Mouse_Move_On_Found Then MouseMove($return[1], $return[2]) Sleep($iSleep_Time) EndIf If $Mouse_Click_On_Found Then MouseClick("left", $return[1], $return[2]) ToolTip('(Press ESC for EXIT) - [' & $sCount & "] Image found:" & " X=" & $return[1] & " Y=" & $return[2], 1, 1) If $Ask_On_Found Then Local $ask = MsgBox(6 + 262144, 'Success [' & $sCount & ']', 'Image found:' & " X=" & $return[1] & " Y=" & $return[2]) If $ask = 2 Or $ask = 3 Or $ask = 5 Or $ask = 7 Then Exit ;No, Abort, Cancel, and Ignore If $ask = 10 Then _ImageSearch_Create_BMP($_Image_1) ; Continue ;Try Again EndIf EndIf Sleep(200) WEnd  
      Video demo:
       
       
      [+] When any problem or error occurs, please make sure that:
      - Downloaded and used the latest version.
      - Set screen Screen Scale and layout = 100%
      - Installed display driver.
      - Tried turning off the antivirus
      - Full installation: Microsoft Visual C++ Redistributable  2005->2022
      [+] You can download the AIO version of the Visual C++ Redistributable here: 
      -> https://www.mediafire.com/file/0ak8dcj9mdn7nyq/VisualCppRedist_AIO_2005-2022_x86_x64_%5Btrong.live%5D.zip/file
      -> FOR Windows XP: https://www.mediafire.com/file/5m5lnr1kfg73tc9/VisualCppRedist_AIO_2005-2019_x86_XP_%5Btrong.live%5D.zip/file
      <!> Password for Extract: trong.live
       
      [+] The last full version of SCITE4AutoIT supports windows XP:
      https://www.autoitscript.com/autoit3/scite/download/archive/v19.1127.1402.0-SciTE4AutoIt3.exe
       
    • By Yirrlaar
      Hello All,
      I'm using "ImageSearch2015.au3" and i'm trying to figure out WHY, for the life of me, I can't find an image is hidden.
      So what I came up with, is as follows:
      _ImageSearchAreaHidden("C:\icon.png", 1, 0, 0, 800, 600, $x1, $y1, 80, 0) Func _ImageSearchAreaHidden($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance, $transparency = 0) Local $h, $result local $TestScreen = "C:\TestScreen.png" ;previsous screenshot of the image looking for, fully visible If Not FileExists($findImage) Then Return "Image File not found" If $transparency <> 0 Then $findImage = "*" & $transparency & " " & $findImage If $tolerance < 0 Or $tolerance > 255 Then $tolerance = 0 If $h_ImageSearchDLL = -1 Then _ImageSearchStartup() If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage $result = DllCall($h_ImageSearchDLL, "str", "ImageSearchEx", "str", $TestScreen, "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage) If @error Then Return "DllCall Error=" & @error If $result = "0" Then Return False $array = StringSplit($result[0], "|") If (UBound($array) >= 4) Then $x = Int(Number($array[2])) ; Get the x,y location of the match $y = Int(Number($array[3])) If $resultPosition = 1 Then $x = $x + Int(Number($array[4]) / 2) ; Account for the size of the image to compute the centre of search $y = $y + Int(Number($array[5]) / 2) EndIf Return True EndIf EndFunc ;==>_ImageSearchAreaHidden Now when the folder with the icon is completely visible, it finds the icon without any issues, however if I cover up the icon, it no longer finds the image in the folder.
      Any ideas?
    • By Yirrlaar
      Here is the thing, I have a picture that has "duplicate" items of what I am searching for.
      I used the windows "paint" to crop a small section of the OVERALL screenshot to use as my search item.
      Now, I have NO issues running the script, as it finds what I am looking for RIGHT AWAY!!! YEAH!!!!
      But if I were to edit the original picture and "remove" the 1st image it finds (the one I "cropped" out) and run the script again, it never finds any of those duplicate images and they are a direct copy & paste of the original image i am trying to find.
      $result = _ImageSearch($picture,0,$x1,$y1,100,0) Is there any other Image Search au3 out there that can made find multiple versions of an image?
    • By computergroove
      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.
    • 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
×
×
  • Create New...