use Win32::GuiTest qw(FindWindowLike WaitWindow WMSetText PushChildButton GetFocus SetFocus); system('"start %windir%\system32\mstsc.exe"'); $Win32::GuiTest::debug = 0; $c=WaitWindow("Remote Desktop Connection",$max_Sleep_time); @windows = FindWindowLike(0, "Remote Desktop Connection"); for (@windows) { $fc_hwnd = GetFocus( $_ ); PushChildButton ($_,Options); SetFocus($fc_hwnd); $set1 = WMSetText($fc_hwnd,"Servername"); $set2 = WMSetText($fc_hwnd+2,"USER_Name"); } sleep(5); PushChildButton( $_, "Co&nnect");