eEniquEe Posted February 28, 2009 Share Posted February 28, 2009 In the Help File, it says that:_ScreenCapture_Capture:If FileName is not blank this function will capture the screen and save it to file. If FileName is blank, this function will capture the screen and return a HBITMAP handle to the bitmap image. In this case, after you are finished with the bitmap you must call _WinAPI_DeleteObject to delete the bitmap handle.So, what I understand is, if I don't specify any File Name, then the captured bitmap (captured from the screen) will be saved to the memory, isn't it?The problem is, how can I extract a pixel out of this captured bitmap? And then read its color? Do I have to read the memory to do this? :-s If yes, can you guys give me a small lesson on how to do it, pls? I haven't met this kind of problem before, so I have absolutely no idea.. Well, I can use the GetPixelColor to grab that pixel's color right from the screen, but it'll be amazingly slow if the number of pixels is large enough; and sometimes, not accurate at all, since all programmes running at that moment 'sync's themselves, so the pixel might get changed. So I think I should another way to get round this problem. Thanks a lot in advance guys. Link to comment Share on other sites More sharing options...
Andreik Posted February 28, 2009 Share Posted February 28, 2009 Try this: #include <ScreenCapture.au3> #include <GDIPlus.au3> #include <Misc.au3> HotKeySet("{ESC}","Quit") _GDIPlus_Startup() $hBitmap = _ScreenCapture_Capture("",0,0,@DesktopWidth,@DesktopHeight,False) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) While 1 If _IsPressed('01') Then $POS = MouseGetPos() TrayTip("Pixel Color",_GDIPlus_BitmapGetPixel($hImage,$POS[0],$POS[1]),1) EndIf Sleep(20) WEnd Func _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY) Local $tArgb, $pArgb, $aRet $tArgb = DllStructCreate("dword Argb") $pArgb = DllStructGetPtr($tArgb) $aRet = DllCall($ghGDIPDll, "int", "GdipBitmapGetPixel", "hwnd", $hBitmap, "int", $iX, "int", $iY, "ptr", $pArgb) Return "0x" & Hex(DllStructGetData($tArgb, "Argb")) EndFunc ;==>_GDIPlus_BitmapGetPixel Func Quit() _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject($hBitmap) _GDIPlus_Shutdown() Exit EndFunc When the words fail... music speaks. Link to comment Share on other sites More sharing options...
jvanegmond Posted February 28, 2009 Share Posted February 28, 2009 Hi,I have even written a UDF to do this. It is very useful when doing OCR or other operations that require a lot of pixel reading.Look here: http://www.autoitscript.com/forum/index.php?showtopic=63318Greetings,Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
eEniquEe Posted February 28, 2009 Author Share Posted February 28, 2009 (edited) Thanks for giving me a big push, guys. Now, it's like 5 time faster than scanning one pixel by one, using PixelGetColor function. Many many thanks.. Just out of curiousity, how do you "know" this DLL, and call it? I just wonder if you guys have any reference to some common DLLs, and its functions? Like this one:$aRet = DllCall($ghGDIPDll, "int", "GdipBitmapGetPixel", "hwnd", $hBitmap, "int", $iX, "int", $iY, "ptr", $pArgb)Honestly, I recently realise that, without using dll's, and Users' Defined Functions, it's really hard, and sometimes, impossible to code in AutoIt; since its main functions are so few.. I know it'll be better if I start learning dll's, so can anyone recommend me some good sites that teach dll? Or, do you have any good .pdf, or book that you think should be a good start for me? :-?Thanks once again. Edited February 28, 2009 by eEniquEe Link to comment Share on other sites More sharing options...
Andreik Posted March 1, 2009 Share Posted March 1, 2009 Just out of curiousity, how do you "know" this DLL, and call it? I just wonder if you guys have any reference to some common DLLs, and its functions? Like this one:$aRet = DllCall($ghGDIPDll, "int", "GdipBitmapGetPixel", "hwnd", $hBitmap, "int", $iX, "int", $iY, "ptr", $pArgb)Make from MSDN your friend.http://msdn.microsoft.com/en-us/library/ms533971(VS.85).aspx When the words fail... music speaks. 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