Bou Posted December 10, 2016 Share Posted December 10, 2016 Helllo guys I have tried to search the forums before posting but nothing solved my problem I included the "imagesearch.au3" and its DLL today and i tried to run it, but i have faced couple of problems, i have tried to install 32x version 64x ... i have tried the old searchimage dll and au3, and the new ones, but nothing solves the problem, not even running it as an admin, installing SciTE4 all over again... Could you guys please help me ? Thanks in advance. Link to comment Share on other sites More sharing options...
Bou Posted December 10, 2016 Author Share Posted December 10, 2016 (edited) i have attached my script and the ImageSearch.au3 that i have downloaded <snip> Edited December 10, 2016 by Melba23 Removed images Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 10, 2016 Moderators Share Posted December 10, 2016 Bou, Welcome to the AutoIt forums. Posting images of your code is not a great help, much better to use Code tags - see here how to do it. 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 Link to comment Share on other sites More sharing options...
Bou Posted December 10, 2016 Author Share Posted December 10, 2016 Okay, sorry didnt know... here's my code: #include <imagesearch.au3> HotKeySet('=', 'start') $x = 0 $y = 0 Func Start() $search = _ImageSearch('capture.bmp', 0, $x, $y, 0) If $search = 1 Then MouseMove($x, $y, 10) EndIf EndFunc ;==>Start While 1 Sleep(100) WEnd and here's the ImageSearch.au3's code: expandcollapse popup#include-once ; ------------------------------------------------------------------------------ ; ; AutoIt Version: 3.0 ; Language: English ; Description: Functions that assist with Image Search ; Require that the ImageSearchDLL.dll be loadable ; ; ------------------------------------------------------------------------------ ;=============================================================================== ; ; Description: Find the position of an image on the desktop ; Syntax: _ImageSearchArea, _ImageSearch ; Parameter(s): ; $findImage - the image to locate on the desktop ; $tolerance - 0 for no tolerance (0-255). Needed when colors of ; image differ from desktop. e.g GIF ; $resultPosition - Set where the returned x,y location of the image is. ; 1 for centre of image, 0 for top left of image ; $x $y - Return the x and y location of the image ; ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 ; ; Note: Use _ImageSearch to search the entire desktop, _ImageSearchArea to specify ; a desktop region to search ; ;=============================================================================== Func _ImageSearch($findImage,$resultPosition,ByRef $x, ByRef $y,$tolerance) return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance) EndFunc Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance) ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom) if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage) ; If error exit if $result[0]="0" then return 0 ; Otherwise get the x,y location of the match and the size of the image to ; compute the centre of search $array = StringSplit($result[0],"|") $x=Int(Number($array[2])) $y=Int(Number($array[3])) if $resultPosition=1 then $x=$x + Int(Number($array[4])/2) $y=$y + Int(Number($array[5])/2) endif return 1 EndFunc ;=============================================================================== ; ; Description: Wait for a specified number of seconds for an image to appear ; ; Syntax: _WaitForImageSearch, _WaitForImagesSearch ; Parameter(s): ; $waitSecs - seconds to try and find the image ; $findImage - the image to locate on the desktop ; $tolerance - 0 for no tolerance (0-255). Needed when colors of ; image differ from desktop. e.g GIF ; $resultPosition - Set where the returned x,y location of the image is. ; 1 for centre of image, 0 for top left of image ; $x $y - Return the x and y location of the image ; ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 ; ; ;=============================================================================== Func _WaitForImageSearch($findImage,$waitSecs,$resultPosition,ByRef $x, ByRef $y,$tolerance) $waitSecs = $waitSecs * 1000 $startTime=TimerInit() While TimerDiff($startTime) < $waitSecs sleep(100) $result=_ImageSearch($findImage,$resultPosition,$x, $y,$tolerance) if $result > 0 Then return 1 EndIf WEnd return 0 EndFunc ;=============================================================================== ; ; Description: Wait for a specified number of seconds for any of a set of ; images to appear ; ; Syntax: _WaitForImagesSearch ; Parameter(s): ; $waitSecs - seconds to try and find the image ; $findImage - the ARRAY of images to locate on the desktop ; - ARRAY[0] is set to the number of images to loop through ; ARRAY[1] is the first image ; $tolerance - 0 for no tolerance (0-255). Needed when colors of ; image differ from desktop. e.g GIF ; $resultPosition - Set where the returned x,y location of the image is. ; 1 for centre of image, 0 for top left of image ; $x $y - Return the x and y location of the image ; ; Return Value(s): On Success - Returns the index of the successful find ; On Failure - Returns 0 ; ; ;=============================================================================== Func _WaitForImagesSearch($findImage,$waitSecs,$resultPosition,ByRef $x, ByRef $y,$tolerance) $waitSecs = $waitSecs * 1000 $startTime=TimerInit() While TimerDiff($startTime) < $waitSecs for $i = 1 to $findImage[0] sleep(100) $result=_ImageSearch($findImage[$i],$resultPosition,$x, $y,$tolerance) if $result > 0 Then return $i EndIf Next WEnd return 0 EndFunc Link to comment Share on other sites More sharing options...
nobbitry Posted December 10, 2016 Share Posted December 10, 2016 (edited) Do you work with a 64bit windows? Maybe you have to add "#AutoIt3Wrapper_UseX64 = Y" on the top of your script. #AutoIt3Wrapper_UseX64 = Y #include <imagesearch.au3> HotKeySet('=', 'start') $x = 0 $y = 0 Func Start() $search = _ImageSearch('capture.bmp', 0, $x, $y, 0) If $search = 1 Then MouseMove($x, $y, 10) EndIf EndFunc ;==>Start While 1 Sleep(100) WEnd Edited December 10, 2016 by nobbitry Bou 1 Link to comment Share on other sites More sharing options...
InunoTaishou Posted December 10, 2016 Share Posted December 10, 2016 This has been asked a lot, a lot of posts in the imagesearch thread, and hundreds of posts on other forums. If (IsArray($result) = False) Then Return 0 Just check to see if it is an array Bou 1 Link to comment Share on other sites More sharing options...
Bou Posted December 10, 2016 Author Share Posted December 10, 2016 8 minutes ago, InunoTaishou said: This has been asked a lot, a lot of posts in the imagesearch thread, and hundreds of posts on other forums. If (IsArray($result) = False) Then Return 0 Just check to see if it is an array Thank you so much. its working now. but only when i "right click" Run script (86x), anyway to make it work with 64x :D? Link to comment Share on other sites More sharing options...
InunoTaishou Posted December 10, 2016 Share Posted December 10, 2016 (edited) Use the proper x64 ImageSearchDLL.dll and you'll have to set your Scite to use the x64 compiler to run scripts and compile scripts if you want to use x64 (I don't remember where this setting is in Scite) Edited December 10, 2016 by InunoTaishou Bou 1 Link to comment Share on other sites More sharing options...
Bou Posted December 10, 2016 Author Share Posted December 10, 2016 Also there seems to be a problem in the SearchImage code, if my code doesnt find the picture looking for The error: "C:\Program Files (x86)\AutoIt3\Include\ImageSearch.au3" (46) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $x = IsArray(Int(Number($array[2]))) $x = IsArray(Int(Number(^ ERROR The original part of the code that has the problem: ; Otherwise get the x,y location of the match and the size of the image to ; compute the centre of search $array = StringSplit($result[0], "|") $x = Int(Number($array[2])) $y = Int(Number($array[3])) If $resultPosition = 1 Then $x = $x + Int(Number($array[4]) / 2) $y = $y + Int(Number($array[5]) / 2) EndIf Return 1 EndFunc ;==>_ImageSearchArea Link to comment Share on other sites More sharing options...
Bert Posted December 10, 2016 Share Posted December 10, 2016 Why do you need to use image search? Why can't you hook into the control you want to interact with? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bou Posted December 11, 2016 Author Share Posted December 11, 2016 I dont think that my answer would help to fix the problem... but whatever... i want to use it to automate games i play Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 11, 2016 Moderators Share Posted December 11, 2016 (edited) You're right, it doesn't help - sounds like you've already seen the forum rules and know this is a topic that is not open for discussion. If you haven't, you need to read them before you post again - especially the part about game automation. Edited December 11, 2016 by JLogan3o13 "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 More sharing options...
Recommended Posts