Akshay07 Posted January 14, 2010 Share Posted January 14, 2010 Hi all, I want to automate the screen capture of a window, and paste it into an excel spreadsheet. What I am doing so far is something like WinActivate ( "MyWindow" ) Send ( "!{PRINTSCREEN}" ) Then I activate excel, select a specific cell and send a CTRL+V to paste the image. It works most of the time, but it appears that it is not 100% reliable (especially on my second laptop, which is not as powerful as the main one, not sure why...). I looked into the help and found _ScreenCapture_CaptureWnd. But if I understand correctly the help, it seems to not work on WinXP "Requires GDI+: GDI+ requires a redistributable for applications that run on the Microsoft Windows NT 4.0 SP6, Windows 2000, Windows 98, and Windows Me operating systems." Are there any other instructions that allow me to take a screen capture of a specific window, and paste it into a document? Thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 14, 2010 Moderators Share Posted January 14, 2010 Akshay07, You have misunderstood (although I grant you that the English is not that clear! ). The OSs mentioned require an additional file to make GDI+ work. Newer OSs (like XP) already have the ability to run GDI+ commands like this. 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...
Akshay07 Posted January 14, 2010 Author Share Posted January 14, 2010 Thanks for the quick answer M23. I was suspecting this Any idea of the instruction to use to paste the HBITMAP handle in a document? Am starting again to digg into the help, but I never refuse a hint Link to comment Share on other sites More sharing options...
Akshay07 Posted January 14, 2010 Author Share Posted January 14, 2010 I found this so far: #Include <ScreenCapture.au3> #Include <Clipboard.au3> $hWnd = WinGetHandle ( "Calculator" ) WinActivate ( "Calculator" ) $hBitmap = _ScreenCapture_CaptureWnd("", $hWnd) _ClipBoard_SetData($hBitmap, $CF_BITMAP) WinActivate ("Document") Send ("^v") Link to comment Share on other sites More sharing options...
Malkey Posted January 14, 2010 Share Posted January 14, 2010 Try this. #include <ScreenCapture.au3> #include <Clipboard.au3> $hWnd = WinGetHandle("Calculator") WinActivate("Calculator") $hBitmap = _ScreenCapture_CaptureWnd("", $hWnd) _ClipBoard_Open($hWnd) _ClipBoard_Empty() _ClipBoard_SetDataEx($hBitmap, $CF_BITMAP) _ClipBoard_Close() WinActivate("Document") Send("^v") Link to comment Share on other sites More sharing options...
Akshay07 Posted January 14, 2010 Author Share Posted January 14, 2010 Thanks, I will try this right now! I am almost where I want to be. I am just wondering if it is possible to take a screen capture of a window without having to use "WinActivate"? Link to comment Share on other sites More sharing options...
Akshay07 Posted January 14, 2010 Author Share Posted January 14, 2010 (edited) Here is where I am now. One huge progress is that I do not need to simulate CTRL+V to paste the screen capture into excel, and I do not need to have excel activated (no need for WinActivate) to paste the image. Now, can I get a proper window capture of "MyWindow" without having to activate this window? $oExcel = ObjCreate( "Excel.Application" ) $oExcel.Visible = 1 $oExcel.WorkBooks.Open ("C:\MyExcel.xls" ) WinExists ("Microsoft Excel - MyExcel.xls") $hWnd = WinGetHandle ( "MyWindow") WinActivate ( "MyWindow" ) ; CAN I AVOID THIS INSTRUCTION? CAN I USE _ScreenCapture_CaptureWnd WITHOUT HAVING TO USE FIRST WinActivate? $hBitmap = _ScreenCapture_CaptureWnd("", $hWnd) _ClipBoard_Open($hWnd) _ClipBoard_Empty() _ClipBoard_SetDataEx($hBitmap, $CF_BITMAP) _ClipBoard_Close() $oExcel.Application.ActiveSheet.Range("B2").Select $oExcel.Application.ActiveSheet.Paste Edited January 14, 2010 by Akshay07 Link to comment Share on other sites More sharing options...
UritOR Posted January 7, 2016 Share Posted January 7, 2016 =) It have been 5.5 years no one looked at it.Any suggestions? I try to find something that works.How to capture a window without activate it. (I need to capture it even if its minimized)Thanx. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 7, 2016 Moderators Share Posted January 7, 2016 UritOR,Rather than necropost, please just start a new thread - although I fear that your quest is in vain.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...
Recommended Posts