Can't bring program to foreground via GUI

M

mark.montemuro

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:mad: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");
}
 
S

smallpond

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top