use Win32::CtrlGUI; # Open file - do other stuff my $window = Win32::CtrlGUI::wait_for_window(qr/$filename/); $window->send_keys("^p{2}{ENTER}!fx");