use Win32::GuiTest qw(FindWindowLike GetWindowText SetForegroundWindow SendKeys); system('"%windir%\system32\mstsc.exe"'); $Win32::GuiTest::debug = 0; my @windows = FindWindowLike(0, "Remote Desktop Connection"); for (@windows) { print "$_>\t'", GetWindowText($_), "'\n"; SetForegroundWindow($_); SendKeys("{ENTER}"); my @windows1 = FindWindowLike(0, "Windows Security",10); for (@windows1) { print "$_>\t'", GetWindowText($_), "'\n"; SetForegroundWindow($_); SendKeys("P@ssword01"); } }