stmdell Posted April 15, 2010 Share Posted April 15, 2010 Hello.. I am trying to use _ScreenCapture_CaptureWnd but have run into an issue. I have the hWnd of the window that I am tyring to capture and the propper cords of the area I want however, if that window is not active then the _ScreenCapture_CaptureWnd function seems to only capture the pixes of the top most window on the screen. For example, I postion the window on the screen and run the code while the app is active using WinActivate($hWnd) and this works great. Next I position the Scite window on top of the app and move it so that Scite is covering that area of the target app. When I rem out the line WinActivate($hWnd), what I end up with is a screen capture of Scite and not the target app. It is almost like _ScreenCapture_CaptureWnd is ignoring the hWnd I passed and only looking at the enitre desktop. I saw a converstaion on this topic but it does not go into enogh details http://www.autoitscript.com/forum/index.php?showtopic=59591 My main question is... if I am passing a handle why does it matter if the window is ontop of all others? Shouldn't the screen cap still work reguardless of its state (top, normal, maximized, minimized, etc)? Thank you... expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.0 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <ScreenCapture.au3> dim $left=527,$top=50,$right=555,$bottom =70 ; cords of the icon on the target app. Opt("WinTitleMatchMode", 4) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Local $hWnd = WinGetHandle("Agent") Local $sHWND = String($hWnd) ; Convert to a string for later use ;Here is the problem line - if this line is not run we get the pixes of the top most window ;if the window is minimized we get a black screen cap of a different size/shape using the same cords ;WinActivate($hWnd) ConsoleWrite ("hwnd=" & $HWND & @CRLF) sleep (1000) FileDelete (@DesktopDir & "\test" & ".jpg") $checksum = PixelChecksum($left,$top,$right,$bottom,1,$hWnd,0) ; This will be used later to determine the state of the icon/area _GetScreenCap($hWnd,$left,$top,$right,$bottom) ;MsgBox(0,"",$sHWND) ; Wait for the region to change, the region is checked every 100ms to reduce CPU load ;~ While $checksum = PixelChecksum(527, 8,540, 20) ;~ Sleep(100) ;~ WEnd ;~ MsgBox(0, "", "Something in the region has changed!") Exit Func _GetScreenCap($hWnd,$left,$top,$right,$bottom ) $SsTake = _ScreenCapture_CaptureWnd("", $hWnd,$left,$top,$right,$bottom,False) _ScreenCapture_SaveImage(@DesktopDir & "\test" & ".jpg", $SsTake) EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 15, 2010 Moderators Share Posted April 15, 2010 stmdell, Welcome to the AutoIt forum. You need to sharpen up your searching skills (although I must admit that the Search function is not the best I have ever seen). Take a look at this topic - using wraithdu's code from post #6 I have just saved an image of a window which is hidden by others. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
stmdell Posted April 26, 2010 Author Share Posted April 26, 2010 Thanks, That helped a bunch.... 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