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

can't close MsgBox from perl script

Expand Messages
  • dwaynekuan
    hi, I m writing a script that produces a MsgBox but when i do that, i notice that control goes to the MsgBox window and the script waits for something to
    Message 1 of 1 , Oct 3, 2004
    • 0 Attachment
      hi, I'm writing a script that produces a MsgBox but when i do that, i
      notice that control goes to the MsgBox window and the script waits for
      something to happen to that MsgBox before continuing.

      is there any way for me to get that script to automatically close that
      msgbox say in 5 seconds?

      the script is as below:



      use Win32;
      use LWP::Simple qw(get);
      use Win32::GuiTest qw(FindWindowLike GetWindowText SetForegroundWindow
      SendKeys);
      $Win32::GuiTest::debug = 1; # Set to "1" to enable verbose mode

      $result = Win32::MsgBox("something is DOWN",48,'test');
      closealertwindow();

      sub closealertwindow
      {
      my @windows = FindWindowLike(undef, "^test!");
      if( !@windows ){
      die "Cannot find window with title/caption\n";
      } else {
      printf( "Window handle of application is %x\n", $windows[ 0 ] );
      sleep 5;
      SetForegroundWindow( $windows[ 0 ] );
      SendKeys("~");
      }
      }
    Your message has been successfully submitted and would be delivered to recipients shortly.