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

Re: [perlguitest] Some Newbie questions

Expand Messages
  • Peter G. Martin
    ... No mouse clicks, but here s a routine I m using with FrameMaker which adds filenames to a FrameMaker book. use Win32::Process; use Win32::GuiTest :ALL ;
    Message 1 of 3 , Aug 2 6:47 PM
    • 0 Attachment
      On Mon, 26 Jul 2004 15:38:15 -0000, Yaron wrote:
      > Hi All
      > I'm trying to automate the running of a windows-based program and
      > since I'm an experienced PERL user, I thought I'd give GUITEST a
      > try. My problem is that I'm not savvy with windows programming
      > (worked a lot with Unix variants).
      > Can anyone point me to an example that shows how to: 1) Identify
      > window 2) Select through menus/submenue 3) enter data in forms 4)
      > Perform mouse-clicks
      >
      No mouse clicks, but here's a routine I'm using with FrameMaker
      which adds filenames to a FrameMaker book.

      use Win32::Process;
      use Win32::GuiTest ':ALL';


      sub addfiles
      {
      # brings in a list of (java) files whose filenames
      # are to be used as the base for FrameMaker (.fm) files
      # to be included into a book file (opened in MIF format)
      my(@bkcomps) = @_;
      # I find this routine from Win32::Process handy in opening
      # the win apps you want
      my ($winObj, $fgWindow, $fmfile);
      Win32::Process::Create(
      $winObj,
      "C:/Program Files/Adobe/FrameMaker7.1/FrameMaker.exe",
      "FrameMaker DDGBk_template.book.MIF",
      0,
      NORMAL_PRIORITY_CLASS,
      "."
      )
      || die( "Couldn't start FrameMaker!\n");

      $winObj->Wait(1);


      $fgWindow = WaitWindowLike(0, "^Adobe FrameMaker", "FrameFamily7.0MdiFrame");
      sleep(2);
      SetForegroundWindow($fgWindow);
      sleep(2);

      SendKeys('{DOW}{DOW}{DOW}{DOW}');
      foreach $fmfile (@bkcomps)
      {
      # select menu item using keystroke shortcut
      # this also sets focus to an open entry field
      # waiting for the filename.
      SendKeys("%A{ENT}");
      sleep(1);
      #
      eval SendKeys("$fmfile");
      sleep(1);
      # negotiate through other fields to the OK button
      # and press it
      SendKeys('{TAB}{TAB}{ENT}');
      sleep(1);
      }
      }


      -Peter G. Martin,
      Technical writer, Proxima Technology
      Not so much a bug -- more a documentation opportunity.
    Your message has been successfully submitted and would be delivered to recipients shortly.