// TARGET:%LocalAppData%\Microsoft\Teams\Update.exe --processStart Teams.exe -a --force-renderer-accessibility // START_IN: using LoginPI.Engine.ScriptBase; //standard class using System; //used for rand and other using System.IO; using System.Diagnostics; using System.Linq; // used for identifying current session ID public class Teams_Guest : ScriptBase { void Execute() { // This should be equal to seconds it takes after starting Host workflow to invite Guest to call var timeToWaitForIncomingCall = 180; var elementTimeout = 20; var longerElementTimeout = 30; var presentationDuration = 120; // 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"); // Give Teams time to render full Window Wait(5); // Reenage Teams Window (might get deleted) var TeamsWindow = FindWindow(className : "Pane:Chrome_WidgetWin_1", title : "*Teams*", processName : "Teams"); // Latch onto Teams bottom-right notification window var TeamsNotificationPopUp = FindWindow(title: "*Teams Notification*", className: "Pane:Chrome_WidgetWin_1", timeout: timeToWaitForIncomingCall); var AcceptVideoCallButton = TeamsNotificationPopUp.FindControl(className: "Button", title: "*Accept video call*"); // Needs to be verified AcceptVideoCallButton.MoveMouseToCenter(); AcceptVideoCallButton.Click(); //Point(x=1674, y=965) rough coordinates of the accept video call button // Identify meeting window var MeetingWindow = FindWindow(title: "Meeting*", className: "Pane:Chrome_WidgetWin_1", timeout: longerElementTimeout); Wait(1); var JoinNowButton = MeetingWindow.FindControl(className: "Button", title: "Join*"); JoinNowButton.MoveMouseToCenter(); JoinNowButton.Click(); // Host will leave the meeting once finished sharing the powerpoint. Once Host leaves, the screen shows "Waiting for others to join..." MeetingWindow.FindControl(className : "Text", title : "Waiting for others*", timeout: timeToWaitForIncomingCall); // Once the Host has left, the Guest should leave as well. var LeaveMeetingButton = MeetingWindow.FindControl(className : "Button", title : "Leave*"); LeaveMeetingButton.MoveMouseToCenter(); LeaveMeetingButton.Click(); // Stop workflow STOP(); } }