Loading ...
Sorry, an error occurred while loading the content.

RE: [perlguitest] Re: Need to move console window running Perl to front

Expand Messages
  • C. Antonio Romero
    Piotr-- I ve pasted my sample code into the mailnote below. A few notes: There s a four second pause due to a call to Win32::Sleep . During that period I
    Message 1 of 6 , Dec 10, 2005
    • 0 Attachment
      Piotr--

      I've pasted my sample code into the mailnote below. A few notes:

      There's a four second pause due to a call to "Win32::Sleep". During that
      period I manually bring other windows to the front by clicking on them in
      the taskbar... this simulates some of the other applications that get opened
      and run during the real perl script I've been working on.

      The "ALT-ESC" key sequence does cycle through windows until the perl
      console comes to the front... but then the call to MsgBox produces a window
      that should be at the top of the z order but is not. You can see it pop up
      in the task bar but you have to manually bring it forward. (I think what I
      will do eventually is use Win32::GUI to create and display a small alert box
      of my own instead, if there's no good way past this in Win32::GuiTest. I
      would imagine that with that I can do pretty much anything I need to, though
      it's more code.)

      Thanks for the help on this. Maybe this is a contrived test case, and the
      real problem is how the MsgBox behaves, but the behavior surprised me.

      -Antonio

      PS-- I think Win32::GuiTest can solve a number of other problems for me--
      I'm very happy to have found it, even if this particular situation has me
      calling for help... Thank you for building this.


      # msgtest.pl
      use Win32;
      use Win32::GuiTest;
      use Win32::GUI;

      my ($hndl)=Win32::GUI::GetPerlWindow();


      # do my other stuff... windows apps open and close
      # To simulate, manually bring other apps to the front
      # by clicking them in the taskbar while "Sleep" call below
      # runs
      # the real script kicks off GUI apps that run
      # for 10 minutes or more and many windows open and close

      Win32::Sleep(4000);


      # cycle windows until the Perl console is in front
      while (Win32::GuiTest::GetForegroundWindow() != $hndl) {
      Win32::GuiTest::SendKeys("%{ESCAPE}");
      }


      # Bring perl console to foreground and activate
      Win32::GuiTest::SetForegroundWindow($hndl);
      Win32::GuiTest::SetActiveWindow($hndl);


      # This message box opens behind other windows
      # (MsgBox should just open in front, I think)
      Win32::MsgBox('Popup',0, 'Text message');




      -----Original Message-----
      From: perlguitest@yahoogroups.com [mailto:perlguitest@yahoogroups.com]On
      Behalf Of Piotr Kaluski
      Sent: Friday, December 09, 2005 1:48 AM
      To: perlguitest@yahoogroups.com
      Subject: [perlguitest] Re: Need to move console window running Perl to front


      OK. I got your point.
      I don't know any simple solution to your problem. But your post
      raised some questions from my side:

      > I tried "%{TAB}" but I ran into an application that that didn't
      work
      > right for... a text editor called Crimson Editor, that I use for my
      > perl code, and that just recognized the alt-tab sequence from
      > SendKeys as just plain TAB characters to enter into the editing
      > buffer. Very strange, that.

      Yes, it is strange. And if you do Alt-TAB manually does this editor
      also intercept it?

      > One more weird thing: If after this procedure I call the
      > Win32::GUI::MsgBox function to display a final confirmation window,
      > that MsgBox appears behind other windows... very annoying, not sure
      > what to do about it.

      Can you send an example code and description of what do you have to
      do to get this behavior?

      --Piotr


      --- In perlguitest@yahoogroups.com, "C.A. Romero" <aromero51@c...>
      wrote:
      >
      > No, unfortunately, SetForegroundWindow on Win2K has a restriction
      > that it can only make a window flash in the taskbar until you give
      it
      > attention by clicking... See:
      >
      > http://support.microsoft.com/kb/q97925
      >
      > I did think of a way to do it-- basically, this:
      >
      > my ($consolehandle)=Win32::GUI::GetPerlWindow();
      > while (Win32::GuiTest::GetForegroundWindow() !=
      > $consolehandle) {
      > Win32::GuiTest::SendKeys("%{ESCAPE}");
      > }
      >
      > It's a bit of a hack but it does cycle the active window until the
      > desired window comes to the foreground.
      >
      > I tried "%{TAB}" but I ran into an application that that didn't
      work
      > right for... a text editor called Crimson Editor, that I use for my
      > perl code, and that just recognized the alt-tab sequence from
      > SendKeys as just plain TAB characters to enter into the editing
      > buffer. Very strange, that.
      >
      > One more weird thing: If after this procedure I call the
      > Win32::GUI::MsgBox function to display a final confirmation window,
      > that MsgBox appears behind other windows... very annoying, not sure
      > what to do about it.
      >
      > Anyway-- Win32::GuiTest is great, I'm not complaining. Thanks for
      the
      > fast reply. If you have any suggestions about the use of MsgBox in
      > this context, I'd appreciate them.
      >
      > -Antonio
      >
      > --- In perlguitest@yahoogroups.com, "Piotr Kaluski" <pkaluski@p...>
      > wrote:
      > >
      > > Doesn't SetForegroundWindow work for you?
      > > --Piotr
      > >
      > > --- In perlguitest@yahoogroups.com, "C.A. Romero"
      <aromero51@c...>
      > > wrote:
      > > >
      > > > Hi,
      > > >
      > > > I have a plain old Perl console application which writes a lot
      of
      > > > info to stdout, kicks off some other GUI based applications
      > > > (Framemaker and Acrobat Distiller, mostly) plus a number of
      other
      > > > console programs that get invoked within the script.
      > > >
      > > > At the end of processing, I need to be able to move the
      > Win2K/WinXP
      > > > console window running the script to the front of the z-order
      of
      > > open
      > > > windows. (The user may well have a number of other windows
      open--
      >
      > > > browsers, mail client, Acrobat Reader, Notepad.)
      > > >
      > > > I'm unable to figure out how to do this simple task. I've been
      > > > experimenting with both Win32::GUI and Win32::GUITest. It seems
      > > like
      > > > one of these should offer a way to do this, and I figure people
      > on
      > > > this list probably know at least something about both...
      > > >
      > > > Thanks for any leads.
      > > >
      > > > -Antonio Romero
      > > >
      > >
      >







      YAHOO! GROUPS LINKS

      Visit your group "perlguitest" on the web.

      To unsubscribe from this group, send an email to:
      perlguitest-unsubscribe@yahoogroups.com

      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
    Your message has been successfully submitted and would be delivered to recipients shortly.