Sign in to follow this  
Followers 0
harch

Help with ImageSearch

7 posts in this topic

#1 ·  Posted (edited)

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
WEnd

Func StartScriptc()
    ;WinActivate("MyWindow")
    FindPicture()
EndFunc

Func StopScript()
    Exit
EndFunc



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

EndFunc

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

For starters, you have a While statement with no WEnd...

What is your end goal? There is likely an easier way to do this beyond an imagesearch..


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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:


function1()
{
    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)
    {
        Send(UP)
        Send(Down)
    }
    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

What do you exactly want to achive? There is usually a much better and reliable way to do it then to search for the _Image. We could help you much better.

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

harch,

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. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

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