Akshay07

Taking a screen capture of a window

9 posts in this topic

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

Share this post


Link to post
Share on other sites



Akshay07,

You have misunderstood (although I grant you that the English is not that clear! :huggles: ). 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. :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks for the quick answer M23.

I was suspecting this :D

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 :huggles:

Share this post


Link to post
Share on other sites

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"?

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 by Akshay07

Share this post


Link to post
Share on other sites

=) 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.

 

Share this post


Link to post
Share on other sites

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.