This sort of thing actually requires a couple of important steps. You need to spawn a separate process to run the application, and you need to interact with the running application from your script to "push the buttons".

Under Windows Win32::Process is probably the best way to run the application independently of your Perl script.

Interacting with the running application from your Perl script is easiest with Win32::GuiTest. Using either of these modules requires a little work. The following is a very brief example to get you started:

use strict; use warnings; use Win32; use Win32::Process; use Win32::GuiTest; my $fileName = 'delme.txt'; my $filePath = "$ENV{TEMP}\\$fileName"; my $app = "$ENV{SystemRoot}\\Notepad.exe"; my $cmd = "notepad $filePath"; my $ProcessObj; unlink $filePath; Win32::Process::Create ($ProcessObj, $app, $cmd, 0, NORMAL_PRIORITY_CL +ASS, ".") || die ErrorReport (); #FindWindowLike($window,$titleregex,$classregex,$childid,$maxlevel) my @windows = Win32::GuiTest::WaitWindow (qr"^Notepad"i, 3); die "Expected to find Notepad's new document dialog\n" if ! @windows; Win32::GuiTest::SetForegroundWindow ($windows[0]); Win32::GuiTest::SendKeys ("%y"); @windows = Win32::GuiTest::WaitWindow (qr"^$fileName"i, 3); die "Expected to find Notepad\n" if ! @windows; Win32::GuiTest::SetForegroundWindow ($windows[0]); Win32::GuiTest::SendKeys ("Hello World%fs%fx"); sub ErrorReport { print Win32::FormatMessage (Win32::GetLastError ()); }
True laziness is hard work

In reply to Re: Perl script stops running on windows after launching another app by GrandFather
in thread Perl script stops running on windows after launching another app by breezykatt

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.