use Win32::GuiTest qw(WaitWindow GetForegroundWindow SetForegroundWindow SendKeys); system("start WINWORD.exe"); sleep 3; $parentWindow = GetForegroundWindow(); SendKeys("%of"); $success = WaitWindow('^Font$',1); print $success;