#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::WinPhoto; my $mw = MainWindow->new(); full_capture(); MainLoop; sub full_capture { my @id = grep { $_ =~ 'Window id' } split( "\n", `xwininfo -root` ); my @ids = split( ' ', $id[0] ); ( my $id ) = grep { $_ =~ /0x/ } @ids; my $image = $mw->Photo( -format => 'Window', -data => oct( $mw->id ), -data => oct('0x00022'), -data => oct($id) ); my $pathname = './rootwindow.' . time . '.png'; $image->write( $pathname, -format => 'BMP | PPM | XPM' ); }