Tinutron Posted May 21, 2009 Share Posted May 21, 2009 hello! I allready know, that it isnt possible to read colors out of an "invisible" window, but i've heard about a method, where people just take a screenshot(using a so called printscreen function) and and pixelsearch this screenshot right from the clipboard. now i have some questions: 1) does this work for opelgl/direct3d applications? 2) is it possible to take a screenshot from a hidden window? 3) can someone post a piece of code, so that it is a little easier for me to understand? i'm relatively new to autoit and this "advanced" functions overcharge me. would be very nice. Link to comment Share on other sites More sharing options...
oMBRa Posted May 22, 2009 Share Posted May 22, 2009 I grabbed this somewhere in the forum, dont remember where CODE #include <GDIPlus.au3> #include <WinAPI.au3> #include <ScreenCapture.au3> _GDIPlus_Startup() ;$hGUI = GUICreate("Screen Capture", 400, 300, @DesktopWidth, @DesktopHeight) ;GUISetState() $hGUI = WinGetHandle("AutoIt Help") WinMove($hGUI, "", @DesktopWidth, @DesktopHeight) $iWidth = _WinAPI_GetWindowWidth($hGUI) $iHeight = _WinAPI_GetWindowHeight($hGUI) $hParent = GUICreate("WindowViewer", 500, 400) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hParent) GUISetState() While 1 $hBMP = _WinCapture($hGUI, $iWidth, $iHeight) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight, 50, 50, 400, 300) _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject($hBMP) Sleep(1000) WEnd Func _WinCapture($hWnd, $iWidth = -1, $iHeight = -1) Local $iH, $iW, $hDDC, $hCDC, $hBMP If $iWidth = -1 Then $iWidth = _WinAPI_GetWindowWidth($hWnd) If $iHeight = -1 Then $iHeight = _WinAPI_GetWindowHeight($hWnd) $hDDC = _WinAPI_GetDC($hWnd) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iWidth, $iHeight) _WinAPI_SelectObject($hCDC, $hBMP) DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "hwnd", $hCDC, "int", 0) ;_WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, 0, 0, 0x00330008) _WinAPI_ReleaseDC($hWnd, $hDDC) _WinAPI_DeleteDC($hCDC) ;_ScreenCapture_SaveImage(@DesktopDir&"\window.jpg", $hBMP) ;_WinAPI_DeleteObject($hBMP) Return $hBMP EndFunc ;==>_WinCapture ibrahem 1 Link to comment Share on other sites More sharing options...
koekje Posted June 23, 2009 Share Posted June 23, 2009 I grabbed this somewhere in the forum, dont remember whereCODE#include <GDIPlus.au3>#include <WinAPI.au3>#include <ScreenCapture.au3>_GDIPlus_Startup();$hGUI = GUICreate("Screen Capture", 400, 300, @DesktopWidth, @DesktopHeight);GUISetState()$hGUI = WinGetHandle("AutoIt Help")WinMove($hGUI, "", @DesktopWidth, @DesktopHeight)$iWidth = _WinAPI_GetWindowWidth($hGUI)$iHeight = _WinAPI_GetWindowHeight($hGUI)$hParent = GUICreate("WindowViewer", 500, 400)$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hParent)GUISetState()While 1 $hBMP = _WinCapture($hGUI, $iWidth, $iHeight) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight, 50, 50, 400, 300) _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject($hBMP) Sleep(1000)WEndFunc _WinCapture($hWnd, $iWidth = -1, $iHeight = -1) Local $iH, $iW, $hDDC, $hCDC, $hBMP If $iWidth = -1 Then $iWidth = _WinAPI_GetWindowWidth($hWnd) If $iHeight = -1 Then $iHeight = _WinAPI_GetWindowHeight($hWnd) $hDDC = _WinAPI_GetDC($hWnd) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iWidth, $iHeight) _WinAPI_SelectObject($hCDC, $hBMP) DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "hwnd", $hCDC, "int", 0) ;_WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, 0, 0, 0x00330008) _WinAPI_ReleaseDC($hWnd, $hDDC) _WinAPI_DeleteDC($hCDC) ;_ScreenCapture_SaveImage(@DesktopDir&"\window.jpg", $hBMP) ;_WinAPI_DeleteObject($hBMP) Return $hBMPEndFunc ;==>_WinCaptureThat's a great function, which works perfectly.However i would also like to know whether it's possible to perform a pixelsearch variant on an image in memory (or file for that matter).I could create a function that uses pixelgetcolor to simulate a pixelsearch, but this is far far slower Link to comment Share on other sites More sharing options...
oMBRa Posted June 23, 2009 Share Posted June 23, 2009 search in the example forum... there is an UDF of Mandar to search pixel from memory 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