Is there a way in Perl to get a list of all the Windows applications
that are running? Basically applications that show in the
Alt-Tab list.
I am just wondering if I can get the desktop coordinates of the
respective windows applications.
Any hint is appreciated.
Something like this may be a start, although I cannot help you with
obtaining desktop/window coordinates.
use Win32::OLE qw(in);
use Win32::OLE::Variant;
my $WMI = Win32::OLE->GetObject($CLASS) || die('WMI instantiation
failed');
# Find all PIDs, program-names, and executable paths for all running
processes.
for my $Process (sort{lc($a->{Name}) cmp lc($b->{Name})} in
($WMI->InstancesOf("Win32_Process")))
{
$Name = $Process->{Name}; # Process program-name.
$Path = $Process->{ExecutablePath}; # Process executable path.
$PID = $Process->{ProcessID}; # PID.
$Path = '' unless (defined($Path));
}
Thanks Dirk,
A working version of your code is as follows:
use strict;
use warnings;
use Win32::OLE qw(in);
use Win32::OLE::Variant;
my $WMI = Win32::OLE->GetObject("winmgmts:\\\\localhost\\root\\cimv2")
|| die('WMI instantiation failed');
for my $Process (sort{lc($a->{Name}) cmp lc($b->{Name})} in
($WMI->InstancesOf("Win32_Process")))
{
my $Name = $Process->{Name}; # Process program-name.
my $Path = $Process->{ExecutablePath}; # Process executable path.
my $PID = $Process->{ProcessID}; # PID.
$Path = '' unless (defined($Path));
print "$Name,$Path,$PID\n";
}
WMI is a good start, but I don't think it exposes the application screen
coordinates.
Thanks anyway.
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs