#! 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(); }