// TARGET:%LocalAppData%\Microsoft\Teams\Update.exe --processStart Teams.exe -a --force-renderer-accessibility // START_IN: /* // Developed by Nick Campa & Brian Martynowicz // Assumptions - Audio/Video settings are pre-configured for the virtual users (i.e. they join with default settings) // Steps: - Open Teams - Click calendar in left-side pane - Click meet now button - Click start meeting button - Click join now button in Teams meeting window (uses default audio/video settings as assumed) - Click invite participants in meeting window popup - Type username to invite */ using LoginPI.Engine.ScriptBase; //standard class using System; //used for rand and other using System.Linq; // used for identifying current session ID using System.Diagnostics; // used for finding processes public class Teams_Host : ScriptBase { void Execute() { var elementTimeout = 10; // standard element timeout var longerElementTimeout = 20; // longer element timeout var standardWait = 3; // standard wait time var usernameToInvite = "username@contoso.com"; // user to invite; this user is searched for within teams meeting and called. var userRealName = "Virtual User"; LoginPI.Engine.ScriptBase.Components.IWindow chatBtn = null; // Kill existing Teams processes var CurrentSessionID = Process.GetCurrentProcess().SessionId; // Get Session id var VerifyTeamsProcess = Process.GetProcessesByName("Teams").Where(p => p.SessionId == CurrentSessionID).Any(); //Verify if current user is running Teams var TeamsProcess= System.Diagnostics.Process.GetProcessesByName("Teams"); if(VerifyTeamsProcess == true) { var RunningProcess = Process.GetProcessesByName("Teams").Where(p => p.SessionId == CurrentSessionID); foreach (var process in RunningProcess) process.Kill(); } START(mainWindowTitle: "*Teams", mainWindowClass: "Pane:Chrome_WidgetWin_1", processName: "Teams"); Wait(5); // Reenage Teams Window (might get deleted) var TeamsWindow = FindWindow(className : "Pane:Chrome_WidgetWin_1", title : "*Teams*", processName : "Teams"); Wait(standardWait, showOnScreen: true); TeamsWindow.Focus(); // Click Calendar button var CalendarButton = TeamsWindow.FindControl(className : "Button", title : "*Calendar*", timeout: elementTimeout); CalendarButton.MoveMouseToCenter(); CalendarButton.Click(); Wait(standardWait, showOnScreen: true, onScreenText: "Let's hold a meeting with Woodrow"); // Click the Meet Now button to create a meeting var MeetNowButton = TeamsWindow.FindControl(className : "Button", title : "*Meet now*"); MeetNowButton.MoveMouseToCenter(); MeetNowButton.Click(); // Click the Start meeting button to initiate the meeting Wait(standardWait, showOnScreen: true); var StartMeetingButton = TeamsWindow.FindControl(className : "Button", title : "*Start meeting*"); StartMeetingButton.MoveMouseToCenter(); StartMeetingButton.Click(); // Lock onto new Meeting window var MeetingWindow = FindWindow(title: "Meeting*", className: "Pane:Chrome_WidgetWin_1", timeout: longerElementTimeout); // Click Join now button to enter bridge var JoinNowButton = MeetingWindow.FindControl(className : "Button", title : "*Join now*", timeout: elementTimeout); var CameraButton = MeetingWindow.FindControl(className : "CheckBox", title : "Camera"); CameraButton.MoveMouseToCenter(); CameraButton.Click(); JoinNowButton.MoveMouseToCenter(); JoinNowButton.Click(); // Click invite participants in popup Wait(3, showOnScreen: true, onScreenText: "Invite participants"); var AddParticipantsPopUpButton = MeetingWindow.FindControl(className : "Button", title : "*Add*", timeout: elementTimeout); AddParticipantsPopUpButton.MoveMouseToCenter(); AddParticipantsPopUpButton.Click(); // Click Meeting Window to reenage focus MeetingWindow.MoveMouseToCenter(); Mouse.Click(); // Move cursor to request to join button Wait(standardWait, showOnScreen: true, onScreenText: $"Let's invite {usernameToInvite}"); Type("{TAB}".Repeat(3)); Wait(standardWait-1); Type($"{usernameToInvite}", cpm: 150); // Invite user to meeting var RequestToJoinButton = MeetingWindow.FindControl(className : "ListItem", title : $"*{userRealName}*"); RequestToJoinButton.MoveMouseToCenter(); MouseMoveBy(dx:100, dy:0); Click(); // User is invited, and assumed to have joined at this point. So we will begin sharing screen. Wait(10); var ShareScreenButton = MeetingWindow.FindControl(className : "Button", title : "Share*", timeout: elementTimeout); ShareScreenButton.MoveMouseToCenter(); ShareScreenButton.Click(); // Select the Window Share button var WindowShareButton = MeetingWindow.FindControl(className : "Button", title : "*active windows*"); WindowShareButton.MoveMouseToCenter(); WindowShareButton.Click(); //This is assuming that a Powerpoint called Login Enterprise Demo 2023.pptx has been accessed recently, or is running. The title can be modified // to reflect a currently running, shareable window that is started from within Virtual User workloads. MeetingWindow.FindControl(className : "Button", title : "Window Login Enterprise Demo 2023.pptx - PowerPoint").MoveMouseToCenter(); Click(); //This will start the Powerpoint presentation, which will be streamed to the guest var PowerPointPresentation = FindWindow(className : "Win32 Window:PPTFrameClass", title : "Login Enterprise Demo 2023.pptx - PowerPoint"); PowerPointPresentation.FindControl(className : "Button:NetUIStickyButton", title : "Slide Show").MoveMouseToCenter(); Click(); var ShareFullScreenButton = MeetingWindow.FindControl(className : "Button", title : "*Monitor*", timeout: elementTimeout); ShareFullScreenButton.MoveMouseToCenter(); ShareFullScreenButton.Click(); Wait(15, showOnScreen: true, onScreenText: "Watching Powerpoint presentation together."); // lower this wait after initial testing. // Once finished presenting, the user should leave the meeting. var LeaveMeetingButton = MeetingWindow.FindControl(className : "Button", title : "Leave*"); LeaveMeetingButton.MoveMouseToCenter(); LeaveMeetingButton.Click(); STOP(); } }