Smokie Posted December 30, 2015 Share Posted December 30, 2015 Hi. I saw some UDFs about image search inside another image and also pixel search, but the problem is that i also need toolerance for imagesearch or shade variation for pixel, because otherwise they can't find it. Any ideas, please please please I am desperate! Link to comment Share on other sites More sharing options...
InunoTaishou Posted December 30, 2015 Share Posted December 30, 2015 I don't quite understand, the Imagesearch function and PixelSearch do exactly what you're asking.What are you trying to automate? Smokie 1 Link to comment Share on other sites More sharing options...
Developers Jos Posted December 30, 2015 Developers Share Posted December 30, 2015 Any ideas, please please please I am desperate!What's on fire? Do you seriously think people can help you when you are this vague?So, when you want us to see whether we can help, you better start giving all details of what you want to do and, more importantly, what you already have tried.JosJos Smokie 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Smokie Posted December 30, 2015 Author Share Posted December 30, 2015 (edited) Sorry, i got caught in my own ideas :). I want to do an ImageSearch Or PixelSearch inside another image file or hBitmap with tolerance/shade-variation. I already found theese libraries to search for bitmaps inside another memory bitmaps, but they won't work all the time:And->But i also need the tolerance parameter for ImageSearch or the shade-variation for PixelSearch. When I use the normal ImageSearch UDF for the screen it only finds the image if I set the tolerance >=32.While 1 $x=0 $y=0 $pos = ImageSearch("test.bmp", 0, $x, $y, 32) If Not @error Then MouseClick("left", $pos[0], $pos[1]) sleep(2000) EndIf WEndThis is what I have tried with BmpSearch on an hBitmap ->; Initialize GDI+ library _GDIPlus_Startup() ;Get the hBitmap of the image i want to search for $Bitmap = _GDIPlus_BitmapCreateFromFile("test.bmp") $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Bitmap) ;Doing the actual window capture and saving it inside $hBMP $iWidth = _WinAPI_GetWindowWidth($browser) ; $browser = the handle of the window which I am capturing $iHeight = _WinAPI_GetWindowHeight($browser) $hDDC = _WinAPI_GetDC($browser) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iWidth, $iHeight) _WinAPI_SelectObject($hCDC, $hBMP) DllCall("User32.dll", "int", "PrintWindow", "hwnd", $browser, "hwnd", $hCDC, "int", 0) ;Searching for the image $pos = _BmpSearch($hBMP, $hBitmap) _ArrayDisplay($pos) ;delete resources _WinAPI_ReleaseDC($browser, $hDDC) _WinAPI_DeleteDC($hCDC) _WinAPI_DeleteObject($hBMP) _GDIPlus_Shutdown()Any idea how to add tolerance to these functions? Edited December 30, 2015 by Smokie Link to comment Share on other sites More sharing options...
InunoTaishou Posted December 30, 2015 Share Posted December 30, 2015 You can use GDIPlus _GDIPlus_BitmapGetPixel to get the pixel color in a memory object. I think ImageSearchDLL.dll has a function that lets you search in hBitmap (Like ImageSearchEx instead of just ImageSearch. I can't confirm this, I just think I saw something about this)Look at the _GDIPlus_BitmapGetPixel in the help file, and you could do your own shade variation by subtracting/adding your tolerance to the color to findIt would look something like$pixel_color = Hex(_GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY), 8) If ($pixel_color < Hex($color_to_find + $color_tolerance, 8) and $pixel_color > Hex($color_to_find - $color_tolerance, 8)) Then(I think my math is right on that, you might want to double check that) Smokie 1 Link to comment Share on other sites More sharing options...
Smokie Posted December 30, 2015 Author Share Posted December 30, 2015 Thanks! I will give it a shot Link to comment Share on other sites More sharing options...
InunoTaishou Posted December 30, 2015 Share Posted December 30, 2015 Just a heads up, _GDIPlus_BitmapGetPixel returns the alpha channel too (the transparency) so it would be formatted 0xFF000000 and 0x00000000 Smokie 1 Link to comment Share on other sites More sharing options...
Smokie Posted December 30, 2015 Author Share Posted December 30, 2015 (edited) Ok so what i have in mind for the pixel search is : capture the hBMP, iterate through its pixels and see if any of them is in that tolerance range. What about the transparency? Edited December 30, 2015 by Smokie Link to comment Share on other sites More sharing options...
InunoTaishou Posted December 30, 2015 Share Posted December 30, 2015 If the color you're looking for is red$color_to_find = 0xFFFF00000xFF = no transparency, FF0000 = Red Smokie 1 Link to comment Share on other sites More sharing options...
Smokie Posted December 30, 2015 Author Share Posted December 30, 2015 I love you man! 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