Sven Posted March 10, 2011 Posted March 10, 2011 It's working here. Something might be blocking the script from accessing the dll file. Are you running on a restricted user account by any chance? Just to make sure, this is what I was using: expandcollapse popup#include <array.au3> $left = 0 $top = 0 $right = @desktopwidth $bottom = @DesktopHeight $file = "user_green.bmp" $findimage = "*" & "transblack" & " " & "*" & 30 & " " & $file $test = _ImageSearchArea($findimage, 0, $left, $top, $right, $bottom, $left, $top, 10) Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance, $transparency = 0) ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom) If not ($transparency = 0) Then $findImage = "*" & $transparency & " " & $findImage If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @LF & 'Before Call') ;### Debug MSGBOX Local $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage) if isarray($result) then _arraydisplay($result) Local $err = @error MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @LF & 'After Call') ;### Debug MSGBOX If $err > 0 Then MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @LF & '$err' & @LF & @LF & 'Return:' & @LF & $err) ;### Debug MSGBOX Return 0 EndIf ; If error exit If $result[0] = "0" Then Return 0 EndIf ; Otherwise get the x,y location of the match and the size of the image to ; compute the centre of search Local $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 The file "user_green.bmp" is from http://www.autoitscript.com/forum/index.php?app=core&module=attach§ion=attach&attach_id=33100
Sven Posted March 30, 2011 Posted March 30, 2011 Now I need some help as well. Here's what I got so far: #include <constants.au3> #include <WinAPI.au3> #include <array.au3> $HBMP = _WinAPI_LoadImage(0, @ScriptDir & '\temp.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE) MsgBox(0, "hbmp", $HBMP) $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", 0, "int", 0, "int", @DesktopWidth, "int", @DesktopHeight, "str", @ScriptDir & "\templates\example.bmp", "ptr", $HBMP) If IsArray($result) Then _ArrayDisplay($result, "result") Else MsgBox(0, "result", $result) EndIf temp.bmp can be accessed and opened, example.bmp can be accessed and opened, yet ImagesearchDLL.dll returns 0. Why's that? ImageSearchDLL.dll is ProgAndy's HBITMAP version from here: Any assistance is greatly appreciated.
Dangerous Posted April 2, 2011 Posted April 2, 2011 (edited) i can not download file please upload again Edited April 2, 2011 by Dangerous
AdmiralAlkex Posted April 2, 2011 Posted April 2, 2011 i can not download file please upload againThe download is fine. Just a few posts up Manadar links to the download on post #63 .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Dangerous Posted April 2, 2011 Posted April 2, 2011 (edited) -Ignore my previous post i have downloadedbut when i make autoitscript and type #include <ImageSearch.au3> and the run such error appears: Edited April 2, 2011 by Dangerous
AdmiralAlkex Posted April 2, 2011 Posted April 2, 2011 Are you running AutoIt in x64 mode?Add:#AutoIt3Wrapper_UseX64=nto use x86 AutoIt.Remember to install SciTE4AutoIt3 if you haven't. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Dangerous Posted April 2, 2011 Posted April 2, 2011 i have the newest version of Autoit SciTE i had but old version now i have updated but the same error appears. -one question where to add#AutoIt3Wrapper_UseX64=n?
AdmiralAlkex Posted April 2, 2011 Posted April 2, 2011 At the top of your script together with the other #AutoIt3Wrapper statements. If you are unsure Press Tools>Compile (or CTRL+F7) from SciTE, change the radio to "Use X86 version" and then press "Save Only". .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Dangerous Posted April 2, 2011 Posted April 2, 2011 (edited) i have reported the error now it works 100% Edited April 3, 2011 by Dangerous
jozzy91 Posted April 4, 2011 Posted April 4, 2011 Hey guys, I like this tool, i am using it for hours now, trying to make a script. But i figured out this tool only returns 1 or 0. I know that pixelsearch will return the position of the pixel. So how can i make this tool to return the X,Y position of the picture? I think i can try to scan the whole screen bit by bit until it reached the picture, but i dont know if it drains too much cpu, anyway ill try that until someone can tell me a better way. Thanks in advance!
jozzy91 Posted April 4, 2011 Posted April 4, 2011 Hmmm i looked at the readme a few times and tried some stuff.. and now i came to the conclusion that i dont get it at all.. lol i think it wont work on vista? ive read some posts about that but no1 really answered hope some1 can answer coz im too tired to figure it outXD
exolon Posted April 8, 2011 Posted April 8, 2011 Hmmm i looked at the readme a few times and tried some stuff..and now i came to the conclusion that i dont get it at all..lol i think it wont work on vista?I'm getting @error=3 when the DLL is called. According to the API docs, this means "function not found". However, looking at the binary, the function name "ImageSearch" seems to be there.Maybe the DLL needs to be rebuilt. Does anyone else have it working on a Windows 7 machine? This is an x64 box but it's configured to run with x86 AutoIt. When running 64-bit, @error=1 instead.
exolon Posted April 8, 2011 Posted April 8, 2011 I'm getting @error=3 when the DLL is called. According to the API docs, this means "function not found". However, looking at the binary, the function name "ImageSearch" seems to be there.Maybe the DLL needs to be rebuilt. Does anyone else have it working on a Windows 7 machine? This is an x64 box but it's configured to run with x86 AutoIt. When running 64-bit, @error=1 instead.Ooh nevermind. It seems to work with the DLL provided in Maybe the ZIP I downloaded had an old DLL build. Perhaps the ZIP could be reuploaded with the latest builds?
armenfrast Posted April 16, 2011 Posted April 16, 2011 (edited) This app is a real pain when you try to use it. Does someone have a working imagesearch on Win7 ? I am not sure which version of the dll i should use and where to put it ? $result contains nothing neither 0 or 1, but void. The code I use ImageSearch demo #AutoIt3Wrapper_UseX64=n #include <Array.au3> #include <ImageSearch.au3> ; ; Demo on the functions of ImageSearch ; MsgBox(0, "MSG", "You need to have an image visible on your screen") $x1 = 0 $y1 = 0 Global $result MsgBox(0, "MSG", "Search for image the top left corner in a 750x750 box") ; find image if it is in the top left corner of screen $result = _ImageSearchArea(@ScriptDir &"\Poubelle.bmp", 1,0,0,750,750, $x1, $y1, 0) If $result = 1 Then MouseMove($x1, $y1, 3) MsgBox(0, "Found", "Found the image in top left corner") Else MsgBox(0, "Néant", "Je n'ai pas trouvé l'image") EndIf ImagesearchArea (part of Imagesearch.au3) 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(@ScriptDir &"\ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage) ; If error exit If $result = "0" Then Return 0 EndIf MsgBox(0,"Result","" & $result) ; Otherwise get the x,y location of the match and the size of the image to ; compute the centre of search $array = StringSplit($result, "|") $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 Edited April 16, 2011 by armenfrast
exolon Posted April 17, 2011 Posted April 17, 2011 This app is a real pain when you try to use it.Does someone have a working imagesearch on Win7 ?I am not sure which version of the dll i should use and where to put it ?Yes. Did you read the last post before yours and try the DLL at that link? It works fine for me on Win 7.
armenfrast Posted April 17, 2011 Posted April 17, 2011 Yes. Did you read the last post before yours and try the DLL at that link? It works fine for me on Win 7.Well, when I use the small DLL (34kb) autoit crashes, and with the big dll (94kb) i get no result.
Fainth Posted May 3, 2011 Posted May 3, 2011 Hi all, i am experimenting with the above version since i want to use the hbitmap version. I am on Win7 64 and already have the 'conventional' imagesearch working fine. But when i try to use this i am out of luck. Anyone has a 'compatible' package of ImageSearch.au3 and corresponding 32bit Dlls that can use hbitmaps ? That would be great since i cannot compile my own version of proper dlls. too much C for me. I tried picking up all the scatered bits of .au3 files and Dlls here all over the place but thats realy a bit 'unsortet'.
qsek Posted September 4, 2011 Posted September 4, 2011 I finally managed to compile the dll on VS 2005 Express.I used the source from ProgAndy with his hbitmap mod.Fixed the memory leak (@ProgAndy line 1121 DeleteDC(xdc) not sdc )modified the behaviour of the search so that the bitmap is searched from start to end and all the match coordinates found in the bitmap are returned in the outputstring.The string looks like this: "123|65#543|67#874|98#...."Also i changed the ImageSearch.au3 to parse the string into a 2dimensional array and this array is returned from ImageSearchArea. Its all in the zip file. Its works for me on win7 64bit with running x86 autoit.exe Im quite a newb in C++ so i didnt know how to implement a proper error checking on the return string, so i simply definedchar answer[500000] = "" ;I think 500k byte for the string are enough for the most purposes Maybe if you use a small pixel bitmap for searching and get lots of results (>50000), the dll may crash, so try to search for more unique patterns.Transparency works with pngs, black pixel and option: *TransBlackI didnt test the toleance option with the new mods but they *should* work.The autoit UDF was wildly changed and is a bit messy, but its working for my purposes.ImageSearchDLL_2dimArray_leak_fixed.rar Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite
diaulas Posted November 22, 2011 Posted November 22, 2011 I finally managed to compile the dll on VS 2005 Express. I used the source from ProgAndy with his hbitmap mod.Fixed the memory leak (@ProgAndy line 1121 DeleteDC(xdc) not sdc )modified the behaviour of the search so that the bitmap is searched from start to end and all the match coordinates found in the bitmap are returned in the outputstring.The string looks like this: "123|65#543|67#874|98#...." Also i changed the ImageSearch.au3 to parse the string into a 2dimensional array and this array is returned from ImageSearchArea. Qsek, any info how to use it? i tried whole desktop : $res = _imagesearcharea(@ScriptDir & '/img/img1.png',0, 0, @DesktopWidth, @DesktopHeight) MsgBox('','asd',$res,1) _ArrayDisplay($res) $res return always 0 I have got working version with another DLL and au3 include(without transparency), but i dont know where im wrong. But your version looks promising, with array and transparency. Any hints?
qsek Posted December 17, 2011 Posted December 17, 2011 (edited) First i dont know what png you are using and if there is a match on your desktop.But i suggest that you look in the imagesearch.au3 and uncomment line 43 because $result is the DLL return Array and will give you more information about whats going on.And you could put in some tolerance:$res = _imagesearcharea(@ScriptDir &'/img/img1.png',0, 0, @DesktopWidth, @DesktopHeight, 40)Also read http://www.autohotkey.com/docs/commands/ImageSearch.htm for the right usage of the options.Like i said, my udf was changed only to made it work for my application. Edited December 17, 2011 by qsek Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite
Recommended Posts