Search the Community
Showing results for tags 'capture_window'.
-
hi brothers, I'm trying to take screenshot from webpage and if found code that could take screenshot even when window is minimized but sometimes i get image like Image Attached I'm trying for 4 hours ago to know where is the problem ... Notice: for some reason I'm need to run site minimized The Code: ;coded by UEZ 2012 #include <Array.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <IE.au3> Opt("WinTitleMatchMode", 2) Local $oIE = _IECreate("https://mybanner.qu.edu.qa/PROD/twbkwbis.P_WWWLogin") opt('winwaitdelay', 0) ;to make it run a little bit faster WinWait("User Login") $handle = WinMove("User Login - Internet Explorer","",0,0,877, 516) WinSetState("User Login","",@SW_SHOWMINIMIZED) _IELoadWait($oIE) Sleep(2000) WinSetState("User Login","",@SW_SHOWDEFAULT) $aWinlist = GetAllWindow() $handle = WinMove("Student Employment Time Attendance","",0,0,877, 516) $MyWindow=WinGetHandle("[Class:IEFrame]") ConsoleWrite($MyWindow) For $i = 0 To UBound($aWinlist) - 1 $hWnd = $aWinlist[$i][1] If Not WinActive($hWnd) Then ExitLoop Next If $i = UBound($aWinlist) Then Exit MsgBox(0, "Info", "No inactive window found", 10) _GDIPlus_Startup() $hBitmap = Capture_Window($MyWindow, 877, 516) _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "Test.jpg") _GDIPlus_BitmapDispose($hBitmap) ShellExecute(@ScriptDir & "Test.jpg") _GDIPlus_Shutdown() Exit Func Capture_Window($hWnd, $w, $h) Local $hDC_Capture = _WinAPI_GetWindowDC($hWnd) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC_Capture) Local $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Capture, $w, $h) Local $hObject = _WinAPI_SelectObject($hMemDC, $hHBitmap) DllCall("user32.dll", "int", "PrintWindow", "hwnd", $hWnd, "handle", $hMemDC, "int", 0) _WinAPI_DeleteDC($hMemDC) ; Local $hObject = _WinAPI_SelectObject($hMemDC, $hObject) _WinAPI_ReleaseDC($hWnd, $hDC_Capture) Local $hBmp = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) _WinAPI_DeleteObject($hHBitmap) Return $hBmp EndFunc ;==>Capture_Window Func GetAllWindow() ;code by Authenticity - modified by UEZ Local $aWin = WinList(), $aWindows[1][4] Local $iStyle, $iEx_Style, $iCounter = 0 Local $i, $hWnd_state, $aWinPos For $i = 1 To $aWin[0][0] $iEx_Style = BitAND(_WinAPI_GetWindowLong($aWin[$i][1], $GWL_EXSTYLE), $WS_EX_TOOLWINDOW) $iStyle = BitAND(WinGetState($aWin[$i][1]), 2) If $iEx_Style <> -1 And Not $iEx_Style And $iStyle Then $aWinPos = WinGetPos($aWin[$i][1]) If $aWinPos[2] > 1 And $aWinPos[3] > 1 Then $aWindows[$iCounter][0] = $aWin[$i][0] $aWindows[$iCounter][1] = $aWin[$i][1] $aWindows[$iCounter][2] = $aWinPos[2] $aWindows[$iCounter][3] = $aWinPos[3] $iCounter += 1 EndIf ReDim $aWindows[$iCounter + 1][4] EndIf Next ReDim $aWindows[$iCounter][4] Return $aWindows EndFunc ;==>GetAllWindow