using LoginPI.Engine.ScriptBase; using System; public class OfficeOutlookForWindows : ScriptBase { private void Execute() { /* Metadata: -Utilizing Windows 10 Professional x86; winver 1909; OS Build 18363.476 -ScriptingToolSet ver. 3.6.23 -Scripting date: V1.0: Dec 23 2019 -Crafted using: -Derived from Microsoft Office 365 ProPlus (flavor) Outlook 16.0.12228.20364 English x64 (Windows desktop installation) -Default compact view, activated, no UI modifications, with a pre-implemented ost/pst/prf, and will open to the Inbox page by default with no initial modal popups or windows */ /* Read me; items to note; caveats: -This script was designed to: -Close Outlook process if already running -Open Outlook and verify it loads to the landing page -Open a new Message window and verify it loads -Open Sent Items view and verify it loads -Open Inbox view and verify it loads -Open Calendar view and verify it loads -Open a new Appointment window and verify it loads -Open Sent Items view and verify it loads -Open Contacts page and verify it loads -Close out of the Outlook application -Please read and set the variables section */ ///////////////////// Starting of variables to define ///////////////////// int GlobalTimeoutInSeconds = 60; // Define how long it should take maximum for operations to complete, such as opening a page in Outlook, in seconds. This script will fail, as designed, if this value is surpassed; example: 60 int WaitSeconds = 1; // Define here how many seconds to wait in between functions; example: 2. This will allow for the target application's UI to catch up int CharactersPerMinuteToType = 999; // Define how many characters per minute the typing function will type; example; 180 ///////////////////// Ending of variables to define ///////////////////// // Starting the script here... // Ensuring the target application isn't already running then starting the target browser ShellExecute(@"cmd /c taskkill /f /im out*",waitForProcessEnd:true,timeout:GlobalTimeoutInSeconds); Wait(WaitSeconds); // This will launch Outlook and verify it opens to the landing page StartTimer(name:"LaunchOutlookToLanding"); START(mainWindowTitle:"Inbox -*",processName:"outlook",timeout:GlobalTimeoutInSeconds); var NewEmailButton = MainWindow.FindControlWithXPath(xPath : "Pane:MsoCommandBarDock/ToolBar:MsoCommandBar/Pane:MsoWorkPane/Pane:NUIPane/Pane:NetUIHWNDElement/Pane:NetUInetpane/Pane:NetUIPanViewer/Custom:NetUIOrderedGroup/Group:NetUIChunk/SplitButton:NetUISplitButtonAnchor/Button:NetUIRibbonButton",timeout:GlobalTimeoutInSeconds); // This will find the New Email button StopTimer(name:"LaunchOutlookToLanding"); Wait(WaitSeconds); // This will open a new email message window; this is encapsulated by a custom timer NewEmailButton.Click(); StartTimer(name:"TimeToNewMessageWindowLoads"); var MessageWindow = FindWindow(title : "*Message*", processName : "OUTLOOK",timeout:GlobalTimeoutInSeconds); MessageWindow.FindControlWithXPath(xPath : "Pane:AfxWndW/Pane:AfxWndW/Pane:AfxWndA/Pane:_WwB/Document:_WwG/Edit",timeout:GlobalTimeoutInSeconds); // This will look for the main body of the new email message window StopTimer(name:"TimeToNewMessageWindowLoads"); MessageWindow.Focus(); Wait(WaitSeconds); MessageWindow.FindControl(className : "Button:NetUIAppFrameHelper", title : "Close").Click(); Wait(WaitSeconds); MainWindow.Focus(); // This will click on the search bar, search for "Sent Items" selection, open Sent Items, and verifies the Sent Items view opens; this is encapsulated in a custom timer MainWindow.FindControl(className : "Edit:NetUISearchBoxTextbox", title : "Just start typing here to bring features to your fingertips and get help.").Click(); Type("Sent Items",cpm:CharactersPerMinuteToType); Wait(WaitSeconds); Type("{enter}",cpm:CharactersPerMinuteToType); StartTimer(name:"TimeToSentItemsPageLoads"); FindWindow(title : "Sent Items*", processName : "OUTLOOK",timeout:GlobalTimeoutInSeconds); StopTimer(name:"TimeToSentItemsPageLoads"); Wait(WaitSeconds); // This will click on the search bar, search for "Inbox" selection, open Inbox, and verifies the Inbox view opens; this is encapsulated in a custom timer MainWindow.FindControl(className : "Edit:NetUISearchBoxTextbox", title : "Just start typing here to bring features to your fingertips and get help.",timeout:GlobalTimeoutInSeconds).Click(); Type("Inbox",cpm:CharactersPerMinuteToType); Wait(WaitSeconds); Type("{enter}",cpm:CharactersPerMinuteToType); StartTimer(name:"TimeToInboxPageLoads"); FindWindow(title : "Inbox*", processName : "OUTLOOK",timeout:GlobalTimeoutInSeconds); MainWindow.FindControlWithXPath(xPath : "Pane:AfxWndW/Win32 Window:NetUINativeHWNDHost/Pane:NetUIHWNDElement/Custom:NetUINetUI/Button:NetUIFolderBarRoot/Button:NetUIStickyButton/Text:NetUILabel",timeout:GlobalTimeoutInSeconds); // This will find the All button StopTimer(name:"TimeToInboxPageLoads"); Wait(WaitSeconds); // This will click on the search bar, search for "Calendar" selection, open Calendar, and verifies the Calendar view opens; this is encapsulated in a custom timer MainWindow.FindControl(className : "Edit:NetUISearchBoxTextbox", title : "Just start typing here to bring features to your fingertips and get help.",timeout:GlobalTimeoutInSeconds).Click(); Type("Calendar",cpm:CharactersPerMinuteToType); Wait(WaitSeconds); Type("{enter}",cpm:CharactersPerMinuteToType); StartTimer(name:"TimeToCalendarPageLoads"); FindWindow(title : "Calendar*", processName : "OUTLOOK",timeout:GlobalTimeoutInSeconds); MainWindow.FindControlWithXPath(xPath : "Pane:NetUINativeHWNDHost/Pane:NetUIHWNDElement/Custom:NetUINetUI/Pane:NetUIScrollViewer/Tree:NetUITreeView/TreeItem:NetUIWBTreeDisplayNode",timeout:GlobalTimeoutInSeconds); // This looks for the My Calendars expander StopTimer(name:"TimeToCalendarPageLoads"); Wait(WaitSeconds); // This will click on the search bar, search for "Appointment" selection, open new appointment, and verifies the new appointment view opens; this is encapsulated in a custom timer MainWindow.FindControl(className : "Edit:NetUISearchBoxTextbox", title : "Just start typing here to bring features to your fingertips and get help.",timeout:GlobalTimeoutInSeconds).Click(); Type("Appointment",cpm:CharactersPerMinuteToType); Wait(WaitSeconds); Type("{enter}",cpm:CharactersPerMinuteToType); StartTimer(name:"TimeToAppointmentPageLoads"); var AppointmentWindow = FindWindow(title : "*Appointment*", processName : "OUTLOOK",timeout:GlobalTimeoutInSeconds); AppointmentWindow.FindControlWithXPath(xPath : "Pane:AfxWndW/Pane:AfxWndW/Pane:AfxWndA/Pane:_WwB/Document:_WwG/Edit",timeout:GlobalTimeoutInSeconds); // This finds the appointment window's main frame/body StopTimer(name:"TimeToAppointmentPageLoads"); Wait(WaitSeconds); AppointmentWindow.Focus(); AppointmentWindow.FindControl(className : "Button:NetUIAppFrameHelper", title : "Close",timeout:GlobalTimeoutInSeconds).Click(); Wait(WaitSeconds); MainWindow.Focus(); // This will click on the search bar, search for "Contacts" selection, open Contacts, and verifies the Contacts view opens; this is encapsulated in a custom timer MainWindow.FindControl(className : "Edit:NetUISearchBoxTextbox", title : "Just start typing here to bring features to your fingertips and get help.",timeout:GlobalTimeoutInSeconds).Click(); Type("Contacts",cpm:CharactersPerMinuteToType); Wait(WaitSeconds); Type("{enter}",cpm:CharactersPerMinuteToType); StartTimer(name:"TimeToContactsPageLoads"); FindWindow(title : "Contacts*", processName : "OUTLOOK",timeout:GlobalTimeoutInSeconds); MainWindow.FindControlWithXPath(xPath : "Pane:NetUINativeHWNDHost/Pane:NetUIHWNDElement/Custom:NetUINetUI/Pane:NetUIScrollViewer/Tree:NetUITreeView/TreeItem:NetUIWBTreeDisplayNode",timeout:GlobalTimeoutInSeconds); // This will find the My Contacts expander StopTimer(name:"TimeToContactsPageLoads"); Wait(WaitSeconds); // This will close out of the Outlook application STOP(); } }