in reply to Capturing the text in a Console Window
Assuming you have two Command windows running. One, currently idle (hence the regex '^command Prompt$'), that you wish to capture whatever is in it's buffer, and the other in which you will invoke this script (which will fail to match the regex because it will have the title text 'Command Prompt - yourname.pl' or similar).
This will capture the contents of the idle sessions buffer and print on the console where you run this script. If you have multiple idle windows, then it will capture and dump them all. Adjust the regex to select the appropriate window.
#! perl -slw use strict; use Win32::GuiTest qw[ FindWindowLike SendKeys SetForegroundWindow ]; use Win32::Clipboard; my $clip = Win32::Clipboard(); for my $w ( FindWindowLike( 0, '^Command Prompt$', 0, 0, 0 ) ) { SetForegroundWindow( $w ); SendKeys( '%{SPC}ES%{SPC}Ey' ); print $clip->Get(); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Capturing the text in a Console Window
by slloyd (Hermit) on Oct 13, 2005 at 16:40 UTC | |
by BrowserUk (Patriarch) on Oct 13, 2005 at 16:56 UTC |