wolf9228 Posted September 18, 2009 Posted September 18, 2009 (edited) PRINTSCREEN ===> ChildWindowsCapture ForegroundWindow ESC ==> Exit expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> Global $Child = "" ,$ChildArray , $PTR_Chi HotKeySet("{PRINTSCREEN}", "ChildWindowsCapture") HotKeySet("{ESC}", "Terminate") While 1 Sleep(20) WEnd Func ChildWindowsCapture() DirCreate(@ScriptDir & "\Capture") $WindowArray = GetChildWindows(WinGetHandle("")) $UBound = UBound($WindowArray) - 1 _GDIPlus_Startup () For $i = 0 To $UBound Step 1 $hBitmap = BitmapCreateFromControlHWND($WindowArray[$i]) $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap) _GDIPlus_ImageSaveToFile ($hBitmap, @ScriptDir & "\Capture\" & $i & ".jpg") _WinAPI_DeleteObject ($hBitmap) Next _GDIPlus_ShutDown () EndFunc Func GetChildWindows($hWndParent) If Not ($PTR_Chi) Then $PTR_Chi = RegisterEnumChildProc("CALLBACK_EnumChildProc") EnumChildWindows($hWndParent , $PTR_Chi) Return $ChildArray EndFunc Func EnumChildWindows($hWndParent , $lpEnumFunc) Local $lParam = 0 Global $Child = "" Global $ChildArray = 0 Dim $ChildArray[1] $BOOL = DllCall("user32.dll","int","EnumChildWindows","hwnd",$hWndParent,"ptr",$lpEnumFunc,"int",$lParam) if Not @error Then Return SetError(@error,"",$BOOL[0]) Return SetError(@error,"",False) EndFunc Func RegisterEnumChildProc($lpEnumFunc) $handle = DLLCallbackRegister ($lpEnumFunc, "int", "hwnd;int") Return DllCallbackGetPtr($handle) EndFunc Func CALLBACK_EnumChildProc($hwnd,$lParam) if Not StringInStr($Child,$hwnd) Then $Child &= $hwnd & "|" ReDim $ChildArray[UBound($ChildArray) + 1] $ChildArray[UBound($ChildArray) - 1] = $hwnd Return True Else Return False EndIf EndFunc Func BitmapCreateFromControlHWND($HWND) Local $Width = _WinAPI_GetWindowWidth($hWnd) Local $Height =_WinAPI_GetWindowHeight($hWnd) $DC = _WinAPI_GetDC($HWND) $CompatibleDC = _WinAPI_CreateCompatibleDC($DC) $hBitmap = _WinAPI_CreateCompatibleBitmap($DC,$Width, $Height) _WinAPI_SelectObject($CompatibleDC, $hBitmap) _WinAPI_BitBlt($CompatibleDC, 0, 0, $Width, $Height, $DC, 0, 0,$SRCCOPY) Return $hBitmap EndFunc Func Terminate() Exit 0 EndFuncChildWindowsCapture.au3 Edited September 18, 2009 by wolf9228 صرح السماء كان هنا
UEZ Posted September 18, 2009 Posted September 18, 2009 (edited) Interesting stuff! Just replace While 1 Wend with e.g. Do Until Not Sleep(20) to avoid high cpu load ;-) Thanks for sharing! UEZ Edited September 18, 2009 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
wolf9228 Posted September 18, 2009 Author Posted September 18, 2009 Interesting stuff! Just replace While 1 Wend with e.g. Do Until Not Sleep(20) to avoid high cpu load ;-) Thanks for sharing! UEZ Welcome Thank you for comment صرح السماء كان هنا
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