Jump to content

ImageSearch Usage Explanation


Centrally
 Share

Recommended Posts

<snip>

I got this error in ImageSearch.au3 but code is fine

<snip>

Any help ?

#########################################################################

No, because from your other thread we know that:

Quote

Hi everyone I am new on AutoIt trying to macro on game

M23

Edited by Melba23
Removed images of code
Link to comment
Share on other sites

  • 1 month later...
On 4/10/2021 at 8:24 AM, MrShady187 said:

Hello all,

 

I have a problem I can't solve by myself 😕

I'm using ImageSearch since years and never had problems, a few weeks ago I resintalled my windows and today AutoIT + SciTE.

Now ImageSearch don't work for me anymore, even the old scripts which worked fine.

I'm using the same windows as before, just reinstalled it.

I get this Error:

"E:\Programs\AutoIt3\Include\ImageSearch.au3" (40) : ==> Subscript used on non-accessible variable.:
if $result[0]="0" then return 0
if $result^ ERROR

Is there anything I have to do before I can use it, like registering the .dll? I tried regsvr32, but I get an error.

The .au3 and .dll are in "E:\Programs\AutoIt3\Include\" and I also tried to copy in the dir where my script is.

I tried the 32- and 64-bit versionof ImageSearch, I also reinstalled AutoIt with 32/64 option.

I also tried a reworked version of ImageSearch:

  Reveal hidden contents

With:

; Error checking goes here
If (IsArray($result) = False) Then Return 0
; If error exit
if $result[0]="0" then return 0

Instead:

; If error exit
if $result[0]="0" then return 0

Thats line 39/40 at the original .au3

With this version I don't get any error, but it still cannot find any image.

I also tried higher tolerance like 1000 and I tried jpg and bmp.

I also tried to install AutoIT on 😄 instead of E: and I restarted PC after install.

I tried it from SciTE (F5) and I compiled it as 32 and 64 version, but nothing works 😕

Here is the code I used to try (but I tested with an old script, what works earlier).

  Reveal hidden contents
#include <ImageSearch.au3>

Global $Paused, $x0 = 0, $y0 = 0

$Del1 = 50
$Del2 = 100
$Del3 = 250
$Del4 = 500
$Del5 = 5000

$tol1 = 50
$tol2 = 100
$tol3 = 250

$Dir=@ScriptDir&"\Pics\"
$Typ1=".jpg"
$Typ2=".bmp"
$Typ3=".gif"

$Test = $Dir&"Test"&$Typ2

$dll = DllOpen("ImageSearchDLL.dll")
$res = 0

HotKeySet("{F1}","Test")
HotKeySet("{F10}","Pause")
HotKeySet("{F11}","Exit_Sc")

While 1
    ToolTip("F1 to start testing..." &@CRLF & "F10 to pause..." &@CRLF & "F11 to exit...", 0, 0)
    Sleep(1000)
WEnd

Func Test()
    ToolTip("Testing..." &@CRLF & "F10 to pause..." &@CRLF & "F11 to exit...", 0, 0)
    While 1
        ;Local $search = _ImageSearchArea(@ScriptDir&'\Pics\Test.bmp', 1, 0, 0, 1920, 1080, $x0, $y0, 1000)
        Local $search = _ImageSearch($Test, 1, $x0, $y0, $tol1)
        If $search = 1 Then
        ;If _ImageSearchArea($Test, 1, 908, 314, 1011, 333, $x0, $y0, $tol1) Then
        ;If _WaitForImageSearch($Test, 5, 1, $x0, $y0, $tol3) Then
        ;If _ImageSearch($Test, 1, $x0, $y0, $tol3) Then
        ;If $res = DllCall($dll, "str", "ImageSearch", "int", 0, "int", 0, "int", 1920, "int", 1080, "str", "*TransFFFFFF *85 G:\Dokumente\AutoIt3\PoE\Pics\Test.bmp") Then
            Sleep($Del1)
            MsgBox(4096, "Info", "Pic found")
        Else
            Sleep($Del1)
            ;MsgBox(4096, "Info", "Pic not found")
        EndIf
    WEnd
EndFunc

Func Pause()        ;F10
    $Paused = Not $Paused
    While $Paused
        ToolTip("Paused..." &@CRLF & "F1 to start testing..." &@CRLF & "F11 to exit...", 0, 0)
        Sleep(1000)
    WEnd
EndFunc

Func Exit_Sc()      ;F11
    exit 0
EndFunc

 

Do someone have any idea what's wrong??

The picture I try to find is in the attachment.

 

Thank you all and best regards.

Test.jpg

Facing same problem with you. Have you found any solution yet?

 

Link to comment
Share on other sites

  • 8 months later...
  • 2 months later...
On 7/3/2021 at 6:19 PM, nklight said:

Facing same problem with you. Have you found any solution yet?

 

Hi, if you have problems with ImageSearch, try to use au3 from this link


The one from this thread is not working for me as well, but the one from link i have pasted works fine (with dll in both system32 and script dir).

 

Link to comment
Share on other sites

  • 3 months later...

Hello,

i have one issue, where maybe someone knows how i can solve it.

The program with imagsearch does work totaly well on one notebook, if i try to run it on another notebook, it does not find the pictures.

I did the same grafic resolution on both notebooks, and i did also have an eye on that scaling is the same amount.

if i do new screenshots on the 2nd notebook it does also work. But i dont wanna do the hole work with the pictures on every client.

My tolerance at imagesearch is 100.

 

Some1 any thoughts?

BR

Link to comment
Share on other sites

Hi all, I am having some trouble with imagesearch returning coordinates for client when I have called that out with AutoItSetOption for PixelCoordMode.

 

 

I have the below set at the top

AutoItSetOption("MouseCoordMode", 2)
AutoItSetOption("PixelCoordMode", 2)
AutoItSetOption("CaretCoordMode", 2)

 

and imagesearch as :

        $T22= _ImageSearch("Images\T22.png", 0, $x3, $y3, 40)
    If $T22= 1 Then
            MouseClick("left", $X3, $y3)

 

 

my client location is at 100,100 so when I am trying to click, X3 and Y3 are both +100 because it’s returning the screen coordinates

Link to comment
Share on other sites

  • Developers
8 hours ago, lenclstr746 said:

ImageSearch not work good at windows 11 someone help pls

You serious think this is a good question when you reread it and expect a proper answer?

on top of that you decided to cross post and new topic yourself....   the next time please simply post one time with all the details! 

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 comment
Share on other sites

  • 5 weeks later...
  • 4 months later...

Hello

Heres my simple code: 

#include "_ImageSearch_UDF.au3"

Local $path = @ScriptDir & "\Data\Images" & "\chest.png"
Local $imagesearch = _ImageSearch($path,100,True)

if FileExists($path) Then
    MsgBox(0, "", $imagesearch[1])
Endif

MouseMove($imagesearch[1], $imagesearch[2],5)

and im having this type of error:

+ DllCall: C:\Users\Wilq\AppData\Local\ImageSearchUDF\ImageSearchDLL_MTXP.dll
! Search not found !

I've downloaded the ImageSearch UDF file from the AutoIt forum and placed the ImageSearch UDF file in the AutoIt "Include" directory.

Its strange but example sripts are working but when im trying to run my code it is not.

Appreciate for any help or hint

 

 

 

Link to comment
Share on other sites

On 3/22/2023 at 1:23 AM, wwilk said:

... type of error:

+ DllCall: C:\Users\Wilq\AppData\Local\ImageSearchUDF\ImageSearchDLL_MTXP.dll
! Search not found !

It's not an error, it says that no found!
You are using png instead of bmp. Take a screenshot and crop it where you want to find it and save it in bmp format.

Regards,
 

Link to comment
Share on other sites

  • 1 month later...

Hey guys,

For those who would need it, here is an updated package which allows image searching using transparency, fixing previous bugs and including an easy example.

Usage: open the search.bmp image, run the script and it will use imagesearch to find the red square on your screen and move your mouse cursor in the middle of the square.

This gives you an easy example on how to find an image (in this example, a red square) using a transparency setting (in this case, using white as the transparency color).

Note that this only works if the image you are searching for (so the red square in this example) is not having transparent pixels itself. 

Some images have what is called an alpha channel mask, which means each pixel has an RGB value but also an alpha channel value which describes the transparency setting of this specific pixel. 
In this case since the ImageSearch transparency feature does not deal with alpha channel masks, it's impossible to find such an image using it. You'll need something more sophisticated :)

ImageSearchTransparency2023.zip

Link to comment
Share on other sites

  • 2 months later...

I face an Issue with the library. 

I have taken a screenshot from a Button and search for it. 

Func checkForImage()
    Local $search = _ImageSearch('images\previewbutton4.bmp', 1, $x, $y, 80)
    If $search = 1 Then
        MouseMove($x+20, $y+40, 2)
    EndIf
EndFunc

the button is found when i open the BMP or the screenshot tool. 
It is NOT found in the application on my screen here at home. At work, all was good and it found the image. I took a new screenshot of the Button but I am not able to make it work 

I have at home 2 Screens (Main screen is identical in model and resolution) and at work 3 Screens. 
I cant figure out why i cant get it to work at home. 
I thought retaking the screenshot would solve the issue but nah. 

Any idea how to move forward? 

Link to comment
Share on other sites

  • Developers
7 hours ago, derocco777 said:

Any idea how to move forward? 

The posted script won't work indeed, so maybe start with posting something that is really used we could look at? ;) 

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 comment
Share on other sites

  • 5 weeks later...

Sorry was on holiday. 
What is the issue with the snippet? 


This is the whole script where i tested the image search: 

 

#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>
#include <ImageSearch2023.au3>


global $y = 0, $x = 0

For $i = 1 to 3000
        checkForImage()
        sleep(1200)
next
    

Func checkForImage()
    Local $search = _ImageSearch('images\previewbutton4.bmp', 1, $x, $y, 80)
    If $search = 1 Then
        MouseMove($x+20, $y+40, 2)
    EndIf
EndFunc

while 1
sleep(200)
WEnd



Issue is still there. In the application the button is not recognized. 
Any ide how to solve this would be highly appreciated. 

Link to comment
Share on other sites

  • 1 year later...

Добрый день! Почему-то при выполнении строки local $search = _ImageSearchArea('check5.bmp', 1, 800, 40, 900, 80, $x, $y, 0) скрипт завершает работу и ничего не происходит, ошибок тоже никаких не показывает. Ставлю контрольную точку сразу после этой команды, но на неё не попадает.

Trans:

Hello! For some reason, when executing the line local $search = _ImageSearchArea('check5.bmp', 1, 800, 40, 900, 80, $x, $y, 0) the script terminates and nothing happens, and it doesn't show any errors. I set a checkpoint right after this command, but it doesn't hit it.

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

Note from M23. This is an English-speaking forum - please use a translator in future

Edited by Melba23
Added translation
Link to comment
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
 Share

×
×
  • Create New...