JotaPx Posted December 12, 2013 Share Posted December 12, 2013 Hey! I've been fighting with the _imagesearch function for the past 3 days. Tried all the scripts and dll versions i could put my hands around (lots!!) BUT every single time i try to execyte the script it fails on the library func: To be true i really need this but i am getting REALLY frustated! any hand on this would be much apreciated. Best regards Link to comment Share on other sites More sharing options...
BrewManNH Posted December 12, 2013 Share Posted December 12, 2013 You should check for @error being 0 or not from the DLLCall before trying to use the array, because if DLLCall fails to access the file, it will set @error to something other than 0. Also, is the DLL in the same folder as the script, and have you tried accessing it with the full path? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
JotaPx Posted December 12, 2013 Author Share Posted December 12, 2013 The script i am building call another that uses a Dll. So my script has an include to get the other 2: Link to comment Share on other sites More sharing options...
BrewManNH Posted December 12, 2013 Share Posted December 12, 2013 Can you please stop posting screenshots of your code? Just post the code, it makes things much easier for everyone, including you, to see what is being done. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
JotaPx Posted December 12, 2013 Author Share Posted December 12, 2013 #include <ImageSearch.au3> HotKeySet("s", "start") $y = 0 $x = 0 Func start() $search = _ImageSearch(@scriptdir&"\wtf.bmp", 1, $x, $y, 0) If $search = 1 Then MouseMove($x, $y, 10) EndIf EndFunc while 1 sleep(333) WEnd 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 ImageSearchDLL.zip Link to comment Share on other sites More sharing options...
BrewManNH Posted December 12, 2013 Share Posted December 12, 2013 Where is the DLL file when you run your script? Are you running this script as a 64bit process, or x86? BTW, >this post explains that exact same problem, easily found by using search. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
JotaPx Posted December 12, 2013 Author Share Posted December 12, 2013 i did read all thats topic from top to bottom, as many others (above 20)... I dont like to create topics just cause i am lazy, i did read plenty Couldnt find a solution for the win7 32bit sistem where i need to run the script. As for the Dll, plz check above, its atached to the previous post. Even knowing how to use the search function, sometimes a line escapes us all. Best regards Link to comment Share on other sites More sharing options...
Solution BrewManNH Posted December 12, 2013 Solution Share Posted December 12, 2013 I asked you where you had the dll file saved on your computer when you run the script, not where a copy could be located. Try changing that DLLCall to use the full path and file name of the dll instead of just the file name like it is now. guestscripter 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
JotaPx Posted December 12, 2013 Author Share Posted December 12, 2013 Just in case i putted it on all related folders. Seems its working! I tought it would take the aux script dir. That detail didnt came into my mind... stupid me. Or maybe i pasted over a newer version, dunno, was getting tired and without patience. A big thank you, thumbs up! (so obvious now i look at it, shame on me) 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