using LoginPI.Engine.ScriptBase; using System; using System.Diagnostics; public class concurrentlyRunningApps_BuiltInWindowsApps : ScriptBase { private void Execute() { /* -Disclaimer: This workload is provided as-is and might need further configuration and customization to work successfully in each unique environment. For further Professional Services-based customization please consult with the Login VSI Support and Services team. Please refer to the Help Center section "Application Customization" for further self-help information regarding workload crafting and implementation. -YouTube video: https://youtu.be/GjTVDiM-WpM -Run the workload against the "target" using Script Editor to ensure it will work before uploading it and testing with it -If needed, configure the Set global variables section of this workload -Go through the workload to understand what it's doing. Comment out any unneeded app tests (code blocks) or add on any needed functional testing -Workload version and changelist: --V1.0 | original -Leave Application running compatibility: false This workload will showcase launching and interacting with multiple applications (built-in Windows applications), whilst keeping all of the applications launched. The workload will switch between the app that is in the "foreground" just as a real user would, but will keep several apps open concurrently, also just as a real user would. The following steps will be performed: -Launch notepad.exe, mspaint.exe, calc.exe, and wordpad.exe -Bring notepad into focus and type to it, bring paint into focus and draw a spiral in it, bring calc into focus and perform a calculation in it, and bring wordpad into focus and type to it -The above steps will be formed again -Lastly, the apps will be closed Developed with: -Scripting Toolset version Login Enterprise 4.4.9 -Last updated on 31 March 2021 -Built in Windows notepad, mspaint, calc, and wordpad -winver Windows 10 Pro x64 20H2 */ // set global vars double globalIntermittentWaitInSeconds = 0.5; int globalFunctionTimeoutInSeconds = 30; int globalCharactersPerMinuteToType = 800; // Optional taskkills preliminarily string[] killprocesses = {"calculator","calc","notepad","wordpad","mspaint","ApplicationFrameHost","win32calc"}; foreach (string i in killprocesses) { foreach (Process proc in Process.GetProcessesByName(i)) { proc.Kill(); } } // This will launch the defined apps StartTimer("NotepadStartTime"); START(mainWindowClass : "Win32 Window:Notepad", mainWindowTitle : "Untitled - Notepad", processName : "notepad",timeout:globalFunctionTimeoutInSeconds); MainWindow.FindControlWithXPath(xPath : "Document:Edit",timeout:globalFunctionTimeoutInSeconds); // This finds the main text editor pane of notepad StopTimer("NotepadStartTime"); Wait(globalIntermittentWaitInSeconds); StartTimer("PaintStartTime"); ShellExecute("mspaint",waitForProcessEnd:false); var paintWindow = FindWindow(className : "Win32 Window:MSPaintApp", title : "Untitled - Paint", processName : "mspaint",timeout:globalFunctionTimeoutInSeconds); paintWindow.FindControlWithXPath(xPath : "Pane:MSPaintView/Pane:Afx:0000*",timeout:globalFunctionTimeoutInSeconds); // This finds the main canvas pane StopTimer("PaintStartTime"); Wait(globalIntermittentWaitInSeconds); StartTimer("CalcStartTime"); ShellExecute("calc",waitForProcessEnd:false); var calcWindow = FindWindow(title : "Calculator",timeout:globalFunctionTimeoutInSeconds); StopTimer("CalcStartTime"); Wait(globalIntermittentWaitInSeconds); StartTimer("WordpadStartTime"); ShellExecute("wordpad",waitForProcessEnd:false); var wordpadWindow = FindWindow(className : "Win32 Window:WordPadClass", title : "Document - WordPad", processName : "wordpad",timeout:globalFunctionTimeoutInSeconds); wordpadWindow.FindControlWithXPath(xPath : "Document:RICHEDIT50W",timeout:globalFunctionTimeoutInSeconds); // This finds the main text editor pane of wordpad StopTimer("WordpadStartTime"); Wait(globalIntermittentWaitInSeconds); // This will bring notepad into focus and type to it MainWindow.Focus(); Wait(globalIntermittentWaitInSeconds); MainWindow.Type(@"Hello, World, I am typing sentence #1 into notepad.",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); // This will bring mspaint into focus and draw a spiral in it paintWindow.Focus(); paintWindow.Maximize(); Wait(globalIntermittentWaitInSeconds); var point = paintWindow.GetBounds(); Wait(globalIntermittentWaitInSeconds); var left = (int)point.X + 400; var top = (int)point.Y + 450; var radius = 10.0; MouseMove(left, top); MouseDown(); for (var angle = 0.0; angle < 6 * Math.PI; angle += Math.PI / 10) { var x = left + Math.Sin(angle) * radius; var y = top + Math.Cos(angle) * radius; MouseMove(x, y); Wait(0.05); radius += 2; } MouseUp(); Wait(globalIntermittentWaitInSeconds); // This will bring calc into focus and calculate in it calcWindow.Focus(); Wait(globalIntermittentWaitInSeconds); calcWindow.Type(@"1+2+3+4+5+6+7+8+9+0=",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); // This will bring wordpad into focus and type to it wordpadWindow.Focus(); Wait(globalIntermittentWaitInSeconds); wordpadWindow.Type(@"Hello, World, I am typing sentence #1 into wordpad.",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); // This will bring notepad into focus again, maximize it and type to it MainWindow.Focus(); Wait(globalIntermittentWaitInSeconds); MainWindow.Type(@"{enter}Hello, World, I am typing sentence #2 into notepad.",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); // This will bring mspaint into focus again, maximize it, and draw another spiral paintWindow.Focus(); paintWindow.Maximize(); Wait(globalIntermittentWaitInSeconds); var point2 = paintWindow.GetBounds(); Wait(globalIntermittentWaitInSeconds); var left2 = (int)point.X + 450; var top2 = (int)point.Y + 500; var radius2 = 10.0; MouseMove(left2, top2); MouseDown(); for (var angle2 = 0.0; angle2 < 6 * Math.PI; angle2 += Math.PI / 10) { var x2 = left2 + Math.Sin(angle2) * radius2; var y2 = top2 + Math.Cos(angle2) * radius2; MouseMove(x2, y2); Wait(0.05); radius2 += 2; } MouseUp(); Wait(globalIntermittentWaitInSeconds); // This will bring calc into focus again, maximize it, clear the previous output, and calculate in it calcWindow.Focus(); Wait(globalIntermittentWaitInSeconds); calcWindow.Type(@"{esc}1*2*3*4*5*6*7*8*9=",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); // This will bring wordpad into focus again, maximize it and type to it wordpadWindow.Focus(); Wait(globalIntermittentWaitInSeconds); wordpadWindow.Type(@"{enter}Hello, World, I am typing sentence #2 into wordpad.",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); // This will close out of the defined, opened apps MainWindow.Focus(); Wait(globalIntermittentWaitInSeconds); MainWindow.Close(); paintWindow.Focus(); Wait(globalIntermittentWaitInSeconds); paintWindow.Close(); calcWindow.Focus(); Wait(globalIntermittentWaitInSeconds); calcWindow.Close(); wordpadWindow.Focus(); Wait(globalIntermittentWaitInSeconds); wordpadWindow.Close(); // ensuring apps arent running anymore string[] postkillprocesses = {"calculator","calc","notepad","wordpad","mspaint","ApplicationFrameHost","win32calc"}; foreach (string i in postkillprocesses) { foreach (Process proc in Process.GetProcessesByName(i)) { proc.Kill(); } } } }