#! perl -slw use strict; use Win32::GuiTest qw[SendKeys FindWindowLike SetForegroundWindow]; ## Start asynchronously system 1, 'notepad'; sleep 1; ## Give it chance to start ## Find it's window id ## Assumes only one copy with 'Untitled' is running. ## It two copies are, it doesn't matter which to use anyway my $wid = ( FindWindowLike 0, "Untitled - Notepad", 0, 0 )[0]; ## Ensure it's on top SetForegroundWindow( $wid ); sleep 1; ## Give it chance to respond ## Send the commands needed. ## If the processing is slow it may be better to break them into chaunks ## and intersperse with sleeps SendKeys ## Open the file menu, then the open dialog, ## enter the name of the file, and hit alt-O "%FO 700695.pl %O" ## Move to the end, add a DATA section and some text . "^{END}__DATA__~This was added automatically using Win32::GuiTest~" ## Open the file menu and save. OPen the file menu and exit. ## Say Yes to quiting . "%fs %fx Y" ## A short delay between keystrokes can help with slow dialogs. , 50;