#!/usr/bin/perl -w use strict; use Win32::Process::Info; use Tk; use Tk::HList; use Tk::ItemStyle; my $mw = MainWindow->new( -width => 350, -title => 'Processes Monitor', -height => 50 ); my $hlist = $mw->Scrolled( "HList", -header => 1, -columns => 3, -scrollbars => 'osoe', -width => 70, -selectbackground => 'White', )->pack( -expand => 1, -fill => 'both' ); my $hStyle = $hlist->ItemStyle( "text", -foreground => "black", -font => "Verdana 8" ); my $rStyle = $hlist->ItemStyle( "text", -foreground => "blue", -background => "white", -font => "Verdana 8" ); $hlist->header('create', 0, -text => 'ID', -style => $hStyle); $hlist->header('create', 1, -text => 'Nome', -style => $hStyle); $hlist->header('create', 2, -text => 'Executável', -style => $hStyle); my $pi = Win32::Process::Info->new ('lobo', 'WMI'); #"lobo" is my machine's name #$pi->Set (elapsed_as_seconds => 0); # In clunks, not seconds. #@pids = $pi->ListPids (); # Get all known PIDs my @info = $pi->GetProcInfo (); # Get the max #%subs = $pi->Subprocesses (); # Figure out subprocess relationships. for (my $p = 0; $p < scalar @info; $p++) { if (!($info[$p]{'ProcessId'})) { $info[$p]{'ProcessId'} = ''; } if (!($info[$p]{'Name'})) { $info[$p]{'Name'} = ''; } if (!($info[$p]{'ExecutablePath'})) { $info[$p]{'ExecutablePath'} = ''; } my $pid = $info[$p]{'ProcessId'}; my $pnm = $info[$p]{'Name'}; my $pex = $info[$p]{'ExecutablePath'}; $hlist->add($p); $hlist->itemCreate($p, 0, -text => "$pid", -style => $rStyle); $hlist->itemCreate($p, 1, -text => "$pnm", -style => $rStyle); $hlist->itemCreate($p, 2, -text => "$pex", -style => $rStyle); } MainLoop;