phuocvovan Posted December 11, 2016 Share Posted December 11, 2016 First . Hello guys . I try to find the solution to fix that error. And i know there was a lot of question like me in the forum. But I also can't fix that error. Thanks in advance. I'm using 32 bit version Here is my code #AutoIt3Wrapper_UseX64=n #include <ImageSearch.au3> #include <array.au3> $ImgWindowsOrange = "C:\Users\Phuoc\Desktop\Lasker image_search\sample_target.png" $X = 0 $Y = 0 _test() Func _test() $test = _ImageSearch($ImgWindowsOrange, 0, $X, $Y, 0) If IsArray($test) Then _ArrayDisplay($test, "test") Else MsgBox(0, "test", $test) EndIf EndFunc ;==>_test Link to comment Share on other sites More sharing options...
nobbitry Posted December 11, 2016 Share Posted December 11, 2016 @Bou, is it you? Bou 1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 11, 2016 Moderators Share Posted December 11, 2016 (edited) nobbitry, Not as far as I can see. M23 Edited December 11, 2016 by Melba23 Weird forum formatting 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...
phuocvovan Posted December 11, 2016 Author Share Posted December 11, 2016 26 minutes ago, nobbitry said: @Bou, is it you? No I have seen that post before Link to comment Share on other sites More sharing options...
nobbitry Posted December 11, 2016 Share Posted December 11, 2016 I have no solution for your problem, but I Think you didn't understand what was meant here: You check if $test is an Array. I think the Function never gives an array back. So this test is no help. Func _test() $test = _ImageSearch($ImgWindowsOrange, 0, $X, $Y, 0) If IsArray($test) Then _ArrayDisplay($test, "test") Else MsgBox(0, "test", $test) EndIf EndFunc ;==>_test You need to insert InunoTaishou's line above the line where the error occur. phuocvovan 1 Link to comment Share on other sites More sharing options...
SadBunny Posted December 11, 2016 Share Posted December 11, 2016 That error comes from within the include file. I don't have that include file, but I'm guessing that either there's some sort of initialization function that you're forgetting to call (there's often comments in there that speak about that) or it's just broken. phuocvovan 1 Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
phuocvovan Posted December 11, 2016 Author Share Posted December 11, 2016 (edited) 13 minutes ago, SadBunny said: That error comes from within the include file. I don't have that include file, but I'm guessing that either there's some sort of initialization function that you're forgetting to call (there's often comments in there that speak about that) or it's just broken. This is ImageSearch.au3 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, $HBMP=0) return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance,$HBMP) EndFunc Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance,$HBMP=0) ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom) if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage If IsString($findImage) Then $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage,"ptr",$HBMP) Else $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"ptr",$findImage,"ptr",$HBMP) EndIf ; 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,$HBMP=0) $waitSecs = $waitSecs * 1000 $startTime=TimerInit() While TimerDiff($startTime) < $waitSecs sleep(100) $result=_ImageSearch($findImage,$resultPosition,$x, $y,$tolerance,$HBMP) 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,$HBMP=0) $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,$HBMP) if $result > 0 Then return $i EndIf Next WEnd return 0 EndFunc ImageSearchDLL.dll Edited December 11, 2016 by phuocvovan Link to comment Share on other sites More sharing options...
nobbitry Posted December 11, 2016 Share Posted December 11, 2016 Hey @phuocvovan, Look at the your error message. There you can read, in which file and in which line the error occurs. Why don't you try out, what I wrote. Maybe ist doesn't help. You will know, when you try it phuocvovan 1 Link to comment Share on other sites More sharing options...
phuocvovan Posted December 11, 2016 Author Share Posted December 11, 2016 1 minute ago, nobbitry said: Hey @phuocvovan, Look at the your error message. There you can read, in which file and in which line the error occurs. Why don't you try out, what I wrote. Maybe ist doesn't help. You will know, when you try it Okay bro. i will try it xD Link to comment Share on other sites More sharing options...
phuocvovan Posted December 11, 2016 Author Share Posted December 11, 2016 Thank you all. I already have fixed that Link to comment Share on other sites More sharing options...
InunoTaishou Posted December 11, 2016 Share Posted December 11, 2016 Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance,$HBMP=0) ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom) if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage If IsString($findImage) Then $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage,"ptr",$HBMP) Else $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"ptr",$findImage,"ptr",$HBMP) EndIf ; Error checking goes here If (IsArray($result) = False) Then Return 0 ; 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 My fix goes right after the DllCall phuocvovan 1 Link to comment Share on other sites More sharing options...
Bou Posted December 24, 2016 Share Posted December 24, 2016 On 12/11/2016 at 2:16 PM, nobbitry said: @Bou, is it you? lol, no. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now