harch Posted April 13, 2015 Posted April 13, 2015 (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 April 13, 2015 by harch
SorryButImaNewbie Posted April 13, 2015 Posted April 13, 2015 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
Moderators JLogan3o13 Posted April 13, 2015 Moderators Posted April 13, 2015 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!
harch Posted April 13, 2015 Author Posted April 13, 2015 (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 April 13, 2015 by harch
SorryButImaNewbie Posted April 13, 2015 Posted April 13, 2015 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.
harch Posted April 13, 2015 Author Posted April 13, 2015 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.
Moderators Melba23 Posted April 13, 2015 Moderators Posted April 13, 2015 harch,Welcome to the AutoIt forum. Its a Script for farming in a pokemon gameUnfortunately 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. 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts