Jump to content
Sign in to follow this  

Help with ImageSearch

Recommended Posts

Hello everyone Im just trying to do a simple image search but i just cant get it to work.

This is the code im using:

#include <ImageSearch.au3>
global $x , $y

HotKeySet ("{F1}",StartScriptc)
HotKeySet ("{F2}",StopScript)

While 1

Func StartScriptc()

Func StopScript()

Func FindPicture()
    While 1
        ConsoleWrite ("Before search" & @CRLF)
    $search =  _ImageSearch("test2.bmp",0,$x,$y,50)
        if $search = 1 Then
            ConsoleWrite ("Found it!" & @CRLF)
            ConsoleWrite ("Fail!" & @CRLF)


When i run this code i get the "Before search" printout but then it just crashes:

--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
Before search
!>14:10:51 AutoIt3.exe ended.rc:-1073741819
+>14:10:51 AutoIt3Wrapper Finished.
>Exit code: 3221225477    Time: 9.844

It always crashes before it reches the lines after the _ImageSearch() function.
Im not the author of the ImageSearch.au3 im using, is it possible there is something wrong there? Are there any other easy ways to implement a simple image search?

Thank you for your help
Ps. Fixed code a little

Edited by harch

Share this post

Link to post
Share on other sites

You dont finish while 1 with WEnd, don't you happen to know Drexis or Surol? They have a similar problem ;) 

Also between line 7-8 you should put a sleep, i guess if you don't want to use every resource you have basicly when you produce a runable code :)

Share this post

Link to post
Share on other sites

Sorry the WEnd is this i just missed it when i pasted my code :(

What i rally want to do is to use it to end a function and then call another when a specific event happens on my screen

something like:

    while (no picture) do
        Send (RIGHT)
        Send (LEFT)
     //when picture detected aka my specific event occured
     call function2()

function2 ()
    mouseKlick (X,Y)
    While (looking for next picture)
    Call next function

Sorry for really bad Pseudocode

ps. I dont know Drexis or Surol :( ill check their threads if i find them)

Edited by harch

Share this post

Link to post
Share on other sites

Its a Script for farming in a pokemon game. So
1. I want my character to move around, in the grass. (alternating move right move left)
2. When a battle occurs (i get the battle screen).
3. I want to stop sending left and right and instead do some mouse klicks.

4. When battle is over (healthbar is empty or whatever good indicator i find)

5. Move in grass again

I have not tried imagesearching ingame yet tho. When trying to learn AutoIt i was looking for a icon in my editor instead.

Share this post

Link to post
Share on other sites


Welcome to the AutoIt forum. :)


Its a Script for farming in a pokemon game

Unfortunately you appear to have missed the >Forum rules on your way in. Please read them now (there is also a link at bottom right of each page) - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. :naughty:

See you soon with a legitimate question I hope. :)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


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
This topic is now closed to further replies.
Sign in to follow this  

  • Create New...