Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
As Corion stated, take a look at Win32::Process and Win32::Process::Info.

Just to show you an example so you can have an idea of how the second one works here's a piece of code that uses Tk to show Process Information (just strip Tk out of it if you need):
#!/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 => 'Name', -style => $hStyle); $hlist->header('create', 2, -text => 'Executable', -style => $hStyle); my $pi = Win32::Process::Info->new (undef, 'WMI'); #$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;
Regards,

In reply to Re: I wish to monitor and react according to windows "Task Manager" by DaWolf
in thread I wish to monitor and react according to windows "Task Manager" by moked

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-19 06:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found