use Tk; use Tk::WinPhoto; my $image = $mw->Photo(-format => 'Window', -data => oct($mw->id)); $image->write($path_name, -format => 'BMP|PPM|XPM');
The window must exist and be visible. Because the code allows you to capture windows not owned by Tk it does not attempt to enforce this. If you are capturing one of Tk's windows then use "$w->update".
If window is mapped, but obscured by other windows then what is captured is the rectangle the window would occupy. This can be considered a feature. For Tk-owned windows "$w->raise" can used to bring window forward.