Can't bring program to foreground via GUI

Discussion in 'Perl Misc' started by mark.montemuro@sig.com, Aug 8, 2008.

  1. Guest

    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");
    }
     
    , Aug 8, 2008
    #1
    1. Advertising

  2. smallpond Guest

    On Aug 8, 2:55 pm, 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
     
    smallpond, Aug 8, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marcel van den Hof
    Replies:
    3
    Views:
    623
    Bruce Barker
    Aug 12, 2005
  2. Replies:
    4
    Views:
    2,463
  3. Luigi Donatello Asero

    Background and foreground colour

    Luigi Donatello Asero, Jul 4, 2004, in forum: HTML
    Replies:
    1
    Views:
    551
    Michael Wilcox
    Jul 4, 2004
  4. Ahmad Hassan

    Changing foreground color on console

    Ahmad Hassan, Nov 6, 2003, in forum: C++
    Replies:
    4
    Views:
    881
    =?iso-8859-1?Q?Juli=E1n?= Albo
    Nov 11, 2003
  5. Replies:
    4
    Views:
    460
Loading...

Share This Page