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

Re: [perlguitest] Re: Automating Console Application

Expand Messages
  • Jason Blakey
    You can try Win32::Process - it s non-blocking... Example use Win32::Process; my $workingDir = . ; my $process; Win32::Process::Create( $process,
    Message 1 of 6 , Apr 25, 2003
    • 0 Attachment
      You can try Win32::Process - it's non-blocking...

      Example

      use Win32::Process;
      my $workingDir = '.';

      my $process;
      Win32::Process::Create(
      $process,
      'path/to/app/app.exe',
      'app.exe -args',
      0,
      DETACHED_PROCESS,
      $workingDir);

      $process || die("No process" . Win32::FormatMessage(Win32::GetLastError));


      Thanks,
      jason


      On Fri, 25 Apr 2003 16:38:18 -0000, brad_e1 wrote
      > Hi Ernesto,
      >
      > First off, thanks for the reply. I appreciate the help that you
      > offered. I do apologize for my delay in responding but I have been
      > out of town for the past three weeks and have not had access to a
      > computer. I tried what you suggested but the problem is that the
      > application that I am calling waits for input (it is menu driven)
      > and the system call blocks until I quit my application. Therefore SendKeys
      > () sends keystrokes to the console after my application exits.
      >
      > I have figured out a way to do it but right now it is a little slow
      > because I do the following:
      > system("start cmd.exe");
      > SendKeys("myprog.exe >> results.txt");
      > However I have to continually start and restart my application
      > because results.txt is locked until my application exits.
      >
      > Is there a way to capture output text directly from the console in
      > windows? I tried WMGetText() but it only appears to capture the
      > console title and I can't figure out how to access the window
      > itself. I can capture text from notepad but a console application
      > appears to behave differently.
      >
      > Brad
      >
      > --- In perlguitest@yahoogroups.com, "Ernesto Guisado" <erngui@a...>
      > wrote:
      > > Hi,
      > >
      > > > system("start $Path/myexe.exe -i config.ini >> output.txt");
      > >
      > > Try
      > >
      > > system("$Path/myexe.exe -i config.ini >> output.txt");
      > >
      > > instead.
      > >
      > > start creates a new console and that messes up the redirection.
      > >
      > > Take into account that once you've redirected the output, you won't
      > > be able to see it on screen, but the program should still respond
      > to
      > > your keystrokes.
      > >
      > > Regards,
      > > Ernesto.
      > >
      > >
      > > --- In perlguitest@yahoogroups.com, "brad_e1" <brad_e1@y...> wrote:
      > > > Hi All,
      > > >
      > > > I have an interactive console application that I am trying to
      > > > automate. I want to send key strokes to an application that I
      > spawn
      > > > using the system call and at the same time capture what the
      > program
      > > > dumps to stdout. I am working in windows XP and I cannot seem to
      > > get
      > > > it to work. I tried redirecting the output of my application to a
      > > > file but it doesn't seem to work because the output file
      > output.txt
      > > > is always empty.
      > > >
      > > > Can anybody tell me what I am doing wrong and if there is a
      > better
      > > > way to do this or provide me an example. I would appreciate any
      > > > assistance that anyone can offer.
      > > >
      > > > Here is a example of what I am doing:
      > > >
      > > > use Win32::GuiTest qw/SendKeys FindWindowLike GetWindowText/;
      > > >
      > > > $Path = "C:/test";
      > > >
      > > > system("start $Path/myexe.exe -i config.ini >> output.txt");
      > > >
      > > > # Allow program time to start up
      > > > sleep(2);
      > > >
      > > > my @windows = FindWindowLike(0, "myexe.exe", "");
      > > >
      > > > SendKeys("A~");
      > > > SendKeys("B~");
      > > > SendKeys("C~");
      > > --
      > > http://triumvir.org
      >
      >
      > To unsubscribe from this group, send an email to:
      > perlguitest-unsubscribe@yahoogroups.com
      >
      >
      >
      > Your use of Yahoo! Groups is subject to
      > http://docs.yahoo.com/info/terms/



      --
      This email from jason blakey - jblakey@...
      "The luckiest guy in the world!"
    • Jim Dawson
      I have a program called tee (a port of the UNIX tee command) which will redirect input to both stdout and a file, use myprogram | tee outputfile will
      Message 2 of 6 , Apr 25, 2003
      • 0 Attachment
        I have a program called 'tee' (a port of the UNIX 'tee' command) which will redirect input to both stdout and a file, use 'myprogram | tee outputfile' will display the output of myprogrm to the console while writing it to outputfile.

        'tee' is a part of the open-source 'UNXUTILS' package which is a collection of Windows ports of various UNIX commands. UNXUTILS can be downloaded from unxutils.sourceforge.net

        -----Original Message-----
        From: "brad_e1" <brad_e1@...>
        To: perlguitest@yahoogroups.com
        Date: Fri, 25 Apr 2003 16:38:18 -0000
        Subject: [perlguitest] Re: Automating Console Application

        Hi Ernesto,

        First off, thanks for the reply. I appreciate the help that you
        offered. I do apologize for my delay in responding but I have been
        out of town for the past three weeks and have not had access to a
        computer. I tried what you suggested but the problem is that the
        application that I am calling waits for input (it is menu driven) and
        the system call blocks until I quit my application. Therefore SendKeys
        () sends keystrokes to the console after my application exits.

        I have figured out a way to do it but right now it is a little slow
        because I do the following:
        system("start cmd.exe");
        SendKeys("myprog.exe >> results.txt");
        However I have to continually start and restart my application
        because results.txt is locked until my application exits.

        Is there a way to capture output text directly from the console in
        windows? I tried WMGetText() but it only appears to capture the
        console title and I can't figure out how to access the window itself.
        I can capture text from notepad but a console application appears to
        behave differently.

        Brad

        --- In perlguitest@yahoogroups.com, "Ernesto Guisado" <erngui@a...>
        wrote:
        > Hi,
        >
        > > system("start $Path/myexe.exe -i config.ini >> output.txt");
        >
        > Try
        >
        > system("$Path/myexe.exe -i config.ini >> output.txt");
        >
        > instead.
        >
        > start creates a new console and that messes up the redirection.
        >
        > Take into account that once you've redirected the output, you won't
        > be able to see it on screen, but the program should still respond
        to
        > your keystrokes.
        >
        > Regards,
        > Ernesto.
        >
        >
        > --- In perlguitest@yahoogroups.com, "brad_e1" <brad_e1@y...> wrote:
        > > Hi All,
        > >
        > > I have an interactive console application that I am trying to
        > > automate. I want to send key strokes to an application that I
        spawn
        > > using the system call and at the same time capture what the
        program
        > > dumps to stdout. I am working in windows XP and I cannot seem to
        > get
        > > it to work. I tried redirecting the output of my application to a
        > > file but it doesn't seem to work because the output file
        output.txt
        > > is always empty.
        > >
        > > Can anybody tell me what I am doing wrong and if there is a
        better
        > > way to do this or provide me an example. I would appreciate any
        > > assistance that anyone can offer.
        > >
        > > Here is a example of what I am doing:
        > >
        > > use Win32::GuiTest qw/SendKeys FindWindowLike GetWindowText/;
        > >
        > > $Path = "C:/test";
        > >
        > > system("start $Path/myexe.exe -i config.ini >> output.txt");
        > >
        > > # Allow program time to start up
        > > sleep(2);
        > >
        > > my @windows = FindWindowLike(0, "myexe.exe", "");
        > >
        > > SendKeys("A~");
        > > SendKeys("B~");
        > > SendKeys("C~");
        > --
        > http://triumvir.org



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



        Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
      Your message has been successfully submitted and would be delivered to recipients shortly.