use Win32::OLE qw(in with); use Win32::GUI; use Win32::GuiTest; sub findSecurityWindow # this method detects whether a security window popped up in Outlook. If it is # the case, it needs to be processed so that the script can be executed. # Else it'll pend. { my $messageClass = "#32770"; my $winName = "Microsoft Outlook"; return Win32::GUI::FindWindow($messageClass,$winName); } sub clearSecurityWindow # this method brings the security window on top of all the others, hence focusing it # and sends it a series of keystrokes in order to validate it. { my $securityHandle = shift; print "shandle : $securityHandle\n"; # debug purposes while ($securityHandle!=Win32::GUI::GetForegroundWindow()) { #Win32::GUI::BringWindowToTop($securityHandle); # doesn't seem enough so let's focus it as well #Win32::GUI::SetFocus($securityHandle); Win32::GUI::SetForegroundWindow($securityHandle); Win32::GUI::Enable($securityHandle); } print "foreground window : Win32::GUI::GetForegroundWindow()"; # now send key sequence that will allow maximum time for code to run # The sequence is as follows : initially the no button is focused... # One tab brings us to cancel, another tab to the time tick box # a spacebar hit will tick the box. Then a tab will select the drop-down # list in order for us to choose the time length. A keypress on the End key will # select maximum time. Then a return key will validate our choice # 2 tabs - spacebar - 1 tab - one end - one return Win32::GuiTest::SendKeys("{TAB}"); Win32::GuiTest::SendKeys("{TAB}"); Win32::GuiTest::SendKeys("{SPACEBAR}"); Win32::GuiTest::SendKeys("{TAB}"); Win32::GuiTest::SendKeys("{END}"); Win32::GuiTest::SendKeys("{ENTER}"); }