Jump to content

ImageSearch Help


Recommended Posts

Hi everyone,

Ive just been messing around with the imagesearch function of autoit, after watching a youtube video tutorial.

But everytime i try and run it, and press the hotkey ive set, the script stops with this error.

C:\Users\Dave-2\Auto IT Scripts\<Removed>\ImageSearch.au3 (40) : ==> Subscript used with non-Array variable.:

if $result[0]="0" then return 0

if $result^ ERROR

This happens even though i have copied everything, exactly in the script that i see on the tutorial but on the video the script work everytime, without any errors at all.

Here is the script from the video, that am trying to run, and yes i have the image and the imagesearch.au3 in the same folder as the script itself.

#include <ImageSearch.au3>

HotKeySet("p", "Start")

$X = 0

$Y = 0

Func Start()

$Search =_ImageSearch("ney.png", 0 ,$X, $Y, 0)

IF $Search = 1 Then

MouseMove($X, $Y, 10)

EndIf

EndFunc

While 1

Sleep(100)

WEnd

Ive attached the image file as well, so you can check to see if thats correctly done. Its a image of part of one of my desktop icons. (ney.png)

Could someone please tell me what am doing wrong ?

Thanks

ie: heres the link to the youtube video that am talking about

http://youtu.be/lrc54kmVqjI

post-73964-0-95104300-1341327126_thumb.p

Edited by Tum
Removed name of game bot that is unrelated.
Link to comment
Share on other sites

You're discussing game automation which is against the rules.

WHAT ??

This isnt anything to do with game automation, this is trying to understand a tutorial that i see on the desktop, where the scripts searches for part of a image onscreen ?

Where do you get game automation from this ???? very strange reply !

Link to comment
Share on other sites

WHAT ??

This isnt anything to do with game automation, this is trying to understand a tutorial that i see on the desktop, where the scripts searches for part of a image onscreen ?

Where do you get game automation from this ???? very strange reply !

Not a strange reply.

Let me quote from your first message...

C:UsersDave-2Auto IT Scripts<Removed>ImageSearch.au3 (40) : ==> Subscript used with non-Array variable.:

if $result[0]="0" then return 0

if $result^ ERROR

If "<Removed>" is not game automation, then I don't know what is. Edited by Valik

Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Link to comment
Share on other sites

Thats is because the imagesearch function is actually downloaded with a <removed> for that <removed> game.

That is nothing to do with the simple thing am trying to figure out.

Imagesearch isnt a command in the autoit, it seems to be something that someone has created and added. And i searched the downloads section of autoit for it and couldnt find it, but i found it there.

I have tried using the pixelgetcolor and pixelsearch commands, but couldnt get them to work, and thought i needed to use the imagesearch function, and that was the only place i could find it from.

Edited by Valik
Link to comment
Share on other sites

This doesn't seem to be game automation. There was an attached image but I don't think it was anything from inside a game (I deleted the attachment but it can be re-added if the OP wishes). I did censor the bot name, though. No point having this show up in search results for that reason.

Link to comment
Share on other sites

Please add my small image back, as that was only a small sample of a random desktop icon, that i was using as a image, so i could try and get the script to find that image.

THe reason been, as am not sure whether its actually the image at fault, causing the error.

I dont think it is, as i removed all the extra space that wasnt image, as the video says, but am not totally sure, that is why i added the image.

Edited by Tum
Link to comment
Share on other sites

Ok, but ill have to upload it here, as i cant seem to edit the first post anymore.

This is my image that i have used for the script to find.

Its a part of a random desktop icon.

Am running my desktop on 1920x1080

Would this be causing the problem, and the image is to big or much for the script to scan ?

This is about a quarter of the actually desktop icon.

post-73964-0-26025100-1341327077_thumb.p

Edited by Tum
Link to comment
Share on other sites

Try varying the tolerance parameter to find the image, right now it has to match exactly with your sample image.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Try varying the tolerance parameter to find the image, right now it has to match exactly with your sample image.

I tried adjusting that but still comes back with the error :(

Link to comment
Share on other sites

Hi guys,

After further googling and searching, ive finally fixed the problem.

It was as simple as running the script using the Run Script (x86)

It would seem that the imagesearch doesnt work in 64 bit windows 7.

Is there anyway to setup SciTe to run the scripts automatically using the (x86) option, using the (F5 - Go) option in SciTE. ??

Link to comment
Share on other sites

If you have the full version of the Scite4Autoit, you can hit F7 to change settings for your script, one of them being whether you run it as x86 or x64. Or you can add #AutoIt3Wrapper_UseX64=n to the top of your script.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

If you have the full version of the Scite4Autoit, you can hit F7 to change settings for your script, one of them being whether you run it as x86 or x64. Or you can add #AutoIt3Wrapper_UseX64=n to the top of your script.

Thank you :)

Edited by Tum
Link to comment
Share on other sites

Thank you :)

So I read through this thread and have posted on other websites about image search as well, and can't seem to get it to work.

I get the exact same error you do

C:UsersDave-2Auto IT Scripts<Removed>ImageSearch.au3 (40) : ==> Subscript used with non-Array variable.:

if $result[0]="0" then return 0

if $result^ ERROR

(except its my directory)

I've tried messing around with the ImageSearch.au3, I've run it in 64 bit, 32 bit, run as admin, still nothing.

Was wondering if anyone else had any tips or tricks on what I should try next.

Please and Thank you :)

Link to comment
Share on other sites

These things should all be preset at the top of your script.

#RequireAdmin

#AutoIt3Wrapper_UseX64=n

#include < Imagesearch.au3>

Also, it will also help if you have the Imagesearch.au3 and the ImagesearchDLL.dll in the same folder as your script.

Link to comment
Share on other sites

TY for the suggestions Kidney.

I've tried the following. I had the ImageSearch.au3 in the include folder (swapping it back and forth between the x64 and x86 versions when i tried both). and I had the DLL in the same folder, and also tried it in my system 32 folder (was told that was the proper place to put it).

At the moment my current set up for my script is I have a folder on my desktop, with my script in it, my picture I want to find "Restart.bmp" and the dll and imagesearch.au3.

I am still getting the same error of

Line 40 (File"C:UsersYekimDesktopTestImagesearch.au3"):

if $result[0]="0" then return 0

if $result^ ERROR

Error: Subscript used with non-Array variable.

This is my very simple script im using, pretty much follows exactly what is written in the youtube video shown above.

#include <ImageSearch.au3>

#RequireAdmin

#AutoIt3Wrapper_UseX64=n

HotKeySet( "{a}" , "_Start")

$X = 0

$Y = 0

Func _Start()

$Restart = _ImageSearch("Restart.bmp", 50, $X, $Y, 0)

If $Restart = 1 Then

MouseMove($X, $Y,10)

EndIf

EndFunc

while 1

sleep(100)

WEnd

Link to comment
Share on other sites

i dont think you have the ImageSearch function setup correctly.

also, the ImageSearch.au3 and ImageSearchDLL.dll need to be in the same folder as your script, as i said before. Create a folder on your desktop and name it "Simple Imagesearch" and place EVERYTHIN in this folder. now when i say EVERYTHING, i mean EVERYTHING. here is a list that EVERYTHING

Your .au3 file

ImageSearch.au3

ImageSearchDLL.dll

the bitmap or png you are trying to search for (Looks like yours is Restart.bmp)

now for your parameters.... i havent had much success with the plain "ImageSearch" function. i would suggest

ImageSearchArea(@ScriptDir & "Restart.bmp", 1, 0, 0, @DesktopWidth, @DesktopHeight, $resultX, $resultY, 100)

Link to comment
Share on other sites

  • 2 months later...

excuse me kidney what you mean by your .au3 file? on my desktop i have a folder with

ImageSearch.au3

ImageSearchDLL.dll

and my picture is a small one ( witch is randomly a icon on my desktop ) witch its a Bnp format

when i start my script i have no error! but .. nothing work i mean nothing happen i have no idee what i do wrong .. this is my script

#RequireAdmin

#include <Imagesearch.au3> |||| the imagesearch is write in red? would that be a error? i dont know.. ||||

$x=0

$y=0

$directory = C:UsersFrederic GirardDesktopimagesearch test

while 1

Sleep(5000)

$Search = _ImageSearch("test.bmp", 0, $X, $Y, 0) |||| the "test.bmp" is write in red.. i have no idee if its a error to or its just the autoit color.. help me ;/

if $search = 1 Then

mousemove($X, $Y, 10)

sleep(500)

EndIf

WEnd

also the image is no more bigger then |---- this size its a part of book of ( winrar )

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...