I want to screenshot a Tk app. I mean, I want the app to screenshoot itself.
To take a selfie.
I found code in the wiki that works very well. Except that it only works
if the application's window has focus. If I Alt+Tab away from it while it's running, the resulting screenshot is just a pitch black screen.
My best guess is nothing can be done because the window manager "unmaps"
the window when I Alt+Tab away from it.
Please tell me that I'm wrong and there is some ninja trick to overcome
this limitation.
Please?
The stolen code:
proc CaptureWindow {win {baseImg ""} {px 0} {py 0}} {
package require Img
# create the base image of win (the root of capturing process)
if {$baseImg eq ""} {
set baseImg [image create photo -format window -data $win]
}
# paste images of win's children on the base image
foreach child [winfo children $win] {
if {![winfo ismapped $child]} continue
set childImg [image create photo -format window -data $child]
regexp {\+(\d*)\+(\d*)} [winfo geometry $child] -> x y
$baseImg copy $childImg -to [incr x $px] [incr y $py]
image delete $childImg
CaptureWindow $child $baseImg $x $y
}
return $baseImg
}
--
Luc
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)