Jump to content

Recommended Posts

Posted

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

  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Posted

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:

Posted

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

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
  • 5 years later...
Posted

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

 

  • Moderators
Posted

UritOR,

Rather than necropost, please just start a new thread - although I fear that your quest is in vain.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...