From: mark.montemuro on
I'm trying to bring a minimized program to the foreground. The
following program is a sample of what I'm trying to do. I am running
on XP Pro. The paint program is launched, but minimized.

Any help would be welcome.


C:\Perl\Win32-GuiTest-1.54\eg>active.pl
Windows:1843712:
* Could not set the window id: 1843712 active
* Window id: 1843712 brought to foreground <<<This never did
happen, even though it said so
1843712> 'untitled - Paint'



use Win32::GuiTest qw(:ALL);
use Win32::GUI;

$Win32::GuiTest::debug = 0; # Set to "1" to enable verbose mode

my @windows = FindWindowLike(0, "Paint", "");
print "Windows:@windows:\n";
for (@windows) {
$window=$_;
Win32::GUI::BringWindowToTop($window);
my $success = 1;

if ( SetActiveWindow($window) ) {
print "* Successfully set the window id: $window active\n";
}
else {
print "* Could not set the window id: $window active\n";
$success = 0;
}
if (SetForegroundWindow($window) ) {
print "* Window id: $window brought to foreground\n";
}
else {
print "* Window id: $window could not be brought to foreground
\n";
$success = 0;
}

print "$_>\t'", GetWindowText($_), "'\n";

SendKeys("%f");
}
From: smallpond on
On Aug 8, 2:55 pm, mark.montem...(a)sig.com wrote:
> I'm trying to bring a minimized program to the foreground. The
> following program is a sample of what I'm trying to do. I am running
> on XP Pro. The paint program is launched, but minimized.
>
> Any help would be welcome.
>
> C:\Perl\Win32-GuiTest-1.54\eg>active.pl
> Windows:1843712:
> * Could not set the window id: 1843712 active
> * Window id: 1843712 brought to foreground <<<This never did
> happen, even though it said so
> 1843712> 'untitled - Paint'
>
> use Win32::GuiTest qw(:ALL);
> use Win32::GUI;

You seem to be missing:

use strict;
use warnings;

> Win32::GUI::BringWindowToTop($window);

I don't see this call in the CPAN docs.

--S