Jump to content

Help with ImageSearch


 Share

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

  • Moderators

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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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:


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
Link to comment
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.

Link to comment
Share on other sites

  • Moderators

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

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:

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

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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