using LoginPI.Engine.ScriptBase; using System.IO; using System; public class windowsVideoEditor_LoginEnterpriseSampleFile : ScriptBase { 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/7mhN4XqF7QI -Run the workload against the "target" using Script Editor to ensure it will work before uploading it and testing with it -Workload version and changelist: --V1.0 | original -Leave Application running compatibility: false This workload will: -Perform editing of a sample video file in the Windows Video Editor app. This should generate use-case graphically intensive-load. The following steps will be performed: -Download and extract sample video file in temp -Launch the Video Editor app -Create a new project and add the sample video file -Add text to the video within the project -Add 3D Effect to the video within the project -Add 3D model to the video within the project -Add an animation to the added 3D model -Apply a theme to the video in the project -Export the video with the edits -Afterward play the entire video in full screen Supplemental information: -If needed, configure the "Set global vars" 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 -Developed with: Login Enterprise Scripting Toolset version 4.7.6, Windows 11 Pro x64 21H2, built in Photos app -Last updated on: 6 Jan 2022 */ // Setting global vars and preparing MouseMove(1,1); int globalFunctionTimeoutInSeconds = 300; int globalCharactersPerMinuteToType = 4000; double globalIntermittentWaitInSeconds = 1; int howLongToPlayVideoFor = 30; var temp = GetEnvironmentVariable("TEMP"); try { File.Delete($"{temp}\\LoginPI\\myVideo.mp4"); Directory.CreateDirectory($"{temp}\\LoginPI"); } catch {} // Copying and extracting the test file try { ShellExecute(@"cmd /c mkdir " + $"{temp}\\LoginPI",timeout:globalFunctionTimeoutInSeconds,waitForProcessEnd:true,continueOnError:true); } catch {} CopyFile(KnownFiles.WebSite,$"{temp}\\LoginPI\\vsiwebsite.zip",overwrite:true); try { UnzipFile($"{temp}\\LoginPI\\vsiwebsite.zip", $"{temp}\\LoginPI\\vsiwebsite",overWrite:true); // Extracting the downloaded sample website } catch {} // Optional -- killing Photos app if it's already open ShellExecute("cmd /c taskkill /f /im ApplicationFrameHost.ex*",waitForProcessEnd:true,timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); // This will launch the Video Editor/Photos app and verify it's running StartTimer("VideoEditorLaunchTime"); ShellExecute(@"cmd /c start ms-photos:",waitForProcessEnd:false); var MainWindow = FindWindow(className : "Win32 Window:ApplicationFrameWindow", title : "Photos", processName : "ApplicationFrameHost",timeout:globalFunctionTimeoutInSeconds); var videoEditorButton = MainWindow.FindControlWithXPath(xPath : "Xaml Window:Windows.UI.Core.CoreWindow/Custom/Pane:ScrollViewer/Group/TabItem:Microsoft.UI.Xaml.Controls.NavigationViewItem[4]",timeout:globalFunctionTimeoutInSeconds); // Find and click on Video Editor button StopTimer("VideoEditorLaunchTime"); MainWindow.Focus(); MainWindow.Maximize(); Wait(globalIntermittentWaitInSeconds); var enjoyingThisAppNoThanksButton = MainWindow.FindControl(className : "Button:Button", title : "No, thanks",timeout:2,continueOnError:true); // Finding an intermittent Enjoying this app popup and dismissing it if it exists if (enjoyingThisAppNoThanksButton != null) { Wait(globalIntermittentWaitInSeconds); enjoyingThisAppNoThanksButton.Click(); Wait(globalIntermittentWaitInSeconds); } videoEditorButton.Click(); // Opening Video editor page and creating new project var newVideoProjectButton = MainWindow.FindControl(className : "Button:AppBarButton", title : "New video project",timeout:globalFunctionTimeoutInSeconds); // Verifying Video Editor page loaded Wait(globalIntermittentWaitInSeconds); newVideoProjectButton.Click(); var nameYourVideo = MainWindow.FindControl(className : "Edit:TextBox", title : "Video name", text : "New video",timeout:globalFunctionTimeoutInSeconds); // Verifying the Name your video popup shows Wait(globalIntermittentWaitInSeconds); nameYourVideo.Click(); Wait(globalIntermittentWaitInSeconds); double unixUTCCurrentMilliseconds = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); // Generating a unique string to name the video as nameYourVideo.Type("{ctrl+a}{back}" + unixUTCCurrentMilliseconds + "{enter}",cpm:globalCharactersPerMinuteToType); // Open existing Login Enterprise test file for video editing var addVideoFileButton = MainWindow.FindControl(className : "Button:AppBarButton", title : "Add",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); addVideoFileButton.Click(); var fromThisPCButton = MainWindow.FindControl(className:"MenuItem:MenuFlyoutItem",title:"From this PC",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); fromThisPCButton.Click(); var openDialogWindowFilenameField = MainWindow.FindControl(className : "Edit:Edit", title : "File name:",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); openDialogWindowFilenameField.Click(); openDialogWindowFilenameField.Type("{ctrl+a}{back}" + $"{temp}\\LoginPI\\vsiwebsite\\ChromeScript\\website\\underwater.mp4" + "{enter}",cpm:globalCharactersPerMinuteToType); StartTimer("LoadVideoTime"); var placeInStoryboardButton = MainWindow.FindControlWithXPath(xPath : "Xaml Window:Windows.UI.Core.CoreWindow/Custom/AppBar:ApplicationBar[1]/Button:AppBarButton",timeout:globalFunctionTimeoutInSeconds); StopTimer("LoadVideoTime"); Wait(globalIntermittentWaitInSeconds); placeInStoryboardButton.Click(); MainWindow.FindControl(className : "Button:AppBarButton", title : "Add title card",timeout:globalFunctionTimeoutInSeconds); // Ensuring the video has been added to Storyboard Wait(globalIntermittentWaitInSeconds); // Add text to the video project MainWindow.FindControl(className : "Button:AppBarButton", title : "Text",timeout:globalFunctionTimeoutInSeconds).Click(); var typeYourTextHereField = MainWindow.FindControl(className : "Edit:TextBox", title : "Type your text here",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); typeYourTextHereField.Click(); typeYourTextHereField.Type("Login Enterprise",cpm:globalCharactersPerMinuteToType); MainWindow.FindControl(className : "Button:Button", title : "Done",timeout:globalFunctionTimeoutInSeconds).Click(); // Add Effects and 3D model to the video project with an animation var threeDEffectsButton = MainWindow.FindControl(className : "Button:AppBarButton", title : "3D effects",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); threeDEffectsButton.Click(); var searchEffectsField = MainWindow.FindControl(className : "Edit:TextBox", title : "Search effects",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); searchEffectsField.Click(); searchEffectsField.Type("{ctrl+a}{back}a{enter}",cpm:globalCharactersPerMinuteToType); Wait(globalIntermittentWaitInSeconds); var firstEffectSearchResult = MainWindow.FindControl(className : "ListItem:GridViewItem", title : "Atomic motion",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); firstEffectSearchResult.Click(); var endOfEffectButton = MainWindow.FindControl(className : "Slider:RangeSelectorThumbContainer", title : "End of effect",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); endOfEffectButton.MoveMouseToCenter(); MouseDown(); MainWindow.FindControl(className : "Button:Button", title : "Cancel",timeout:globalFunctionTimeoutInSeconds).MoveMouseToCenter(); // This will apply the 3D Effect to the entire video MouseUp(); var threeDLibraryButton = MainWindow.FindControl(className : "TabItem:PivotItem", title : "Add 3D model",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); threeDLibraryButton.Click(); var first3DLibraryCategoryResult = MainWindow.FindControlWithXPath(xPath : "Xaml Window:Windows.UI.Core.CoreWindow/Tab:Pivot/TabItem:PivotItem[2]/List:GridView/ListItem:GridViewItem",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); first3DLibraryCategoryResult.Click(); var first3DLibraryModelResult = MainWindow.FindControlWithXPath(xPath : "Xaml Window:Windows.UI.Core.CoreWindow/Tab:Pivot/TabItem:PivotItem[2]/List:GridView/ListItem:GridViewItem",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); first3DLibraryModelResult.Click(); MainWindow.FindControl(className : "Button:Button", title : "Done",timeout:globalFunctionTimeoutInSeconds).Click(); int addTitleCardButtonLookLoopNumber = 0; // Ensuring the 3D model has loaded/download by looking for the loading modal dialog to be gone while(addTitleCardButtonLookLoopNumber < 999) { Log(addTitleCardButtonLookLoopNumber); addTitleCardButtonLookLoopNumber++; var addTitleCardButton = MainWindow.FindControl(className : "Button:AppBarButton", title : "Add title card",timeout:2,continueOnError:true); if (addTitleCardButton != null) { break; } MainWindow.FindControl(className : "Button:Button", title : "Done",timeout:2,continueOnError:true).Click(); } Wait(globalIntermittentWaitInSeconds); threeDEffectsButton.Click(); var firstEditableItem = MainWindow.FindControlWithXPath(xPath : "Xaml Window:Windows.UI.Core.CoreWindow/Tab:Pivot/TabItem:PivotItem/List:ListView/ListItem:ListViewItem",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); firstEditableItem.Click(); var quickAnimationsComboBox = MainWindow.FindControlWithXPath(xPath : "Xaml Window:Windows.UI.Core.CoreWindow/Tab:Pivot/TabItem:PivotItem/List:ListView/ListItem:ListViewItem/ComboBox:ComboBox",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); quickAnimationsComboBox.Click(); Wait(globalIntermittentWaitInSeconds); MainWindow.Type("{down}{enter}",cpm:globalCharactersPerMinuteToType); // This should select the Turntable animation from the drop down menu Wait(globalIntermittentWaitInSeconds); MainWindow.FindControl(className : "Button:Button", title : "Done",timeout:globalFunctionTimeoutInSeconds).Click(); // Apply a theme to the video project var seeMoreUpperRightButton = MainWindow.FindControl(className : "Button:Button", title : "More app bar",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); seeMoreUpperRightButton.Click(); var themesButton = MainWindow.FindControl(className:"Button:AppBarButton",title:"Themes",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); themesButton.Click(); var firstThemeButton = MainWindow.FindControlWithXPath(xPath : "Xaml Window:Windows.UI.Core.CoreWindow/Xaml Window:Popup[1]/Pane:ScrollViewer/List:ListView/ListItem:ListViewItem[1]",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); firstThemeButton.Click(); Wait(globalIntermittentWaitInSeconds); MainWindow.FindControl(className : "Button:Button", title : "Done").Click(); // Closing theme dialog MainWindow.FindControl(className : "Button:Button", title : "More app bar",timeout:globalFunctionTimeoutInSeconds).Click(); // Ensuring the Theme has loaded/download by looking for the loading modal dialog to be gone, by finding on the More app bar and looking for its contents to load MainWindow.FindControl(className:"Button:AppBarButton",title:"Themes",timeout:2,continueOnError:true); // Looking for contents within int themeButtonLookLoopNumber = 0; // Ensuring the Theme has loaded/download by looking for the loading modal dialog to be gone while(themeButtonLookLoopNumber < 999) { Log(themeButtonLookLoopNumber); themeButtonLookLoopNumber++; var themeButton = MainWindow.FindControl(className:"Button:AppBarButton",title:"Themes",timeout:2,continueOnError:true); // Looking for contents within the drop down if (themeButton != null) { break; } MainWindow.FindControl(className : "Button:Button", title : "More app bar",timeout:2,continueOnError:true).Click(); // Finding and clicking on the upper right "More app bar" button } Wait(globalIntermittentWaitInSeconds); MainWindow.FindControl(className : "Button:Button", title : "More app bar",timeout:globalFunctionTimeoutInSeconds).Click(); // Collapsing the upper right "More app bar" button // Finishing and saving the video var finishVideoButton = MainWindow.FindControl(className : "Button:AppBarButton", title : "Finish video",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); finishVideoButton.Click(); var exportButton = MainWindow.FindControl(className : "Button:Button", title : "Export",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); exportButton.Click(); var saveAsFileNameField = MainWindow.FindControl(className : "Edit:Edit", title : "File name:",timeout:globalFunctionTimeoutInSeconds); Wait(globalIntermittentWaitInSeconds); saveAsFileNameField.Click(); Wait(globalIntermittentWaitInSeconds); saveAsFileNameField.Type("{ctrl+a}{back}" + $"{temp}\\LoginPI\\myVideo" + "{enter}",cpm:globalCharactersPerMinuteToType); // Play the video file for defined amount of time; video will play automatically after exporting StartTimer("ExportVideoTime"); var exportedVideoPlayerWindow = FindWindow(className : "Win32 Window:ApplicationFrameWindow", title : "myVideo* ‎- Photos", processName : "ApplicationFrameHost",timeout:globalFunctionTimeoutInSeconds); var fullscreenButton = exportedVideoPlayerWindow.FindControlWithXPath(xPath : "Xaml Window:Windows.UI.Core.CoreWindow/Button:Button",timeout:globalFunctionTimeoutInSeconds); StopTimer("ExportVideoTime"); exportedVideoPlayerWindow.Focus(); exportedVideoPlayerWindow.Maximize(); Wait(globalIntermittentWaitInSeconds); fullscreenButton.Click(); MouseMove(1,1); Wait(howLongToPlayVideoFor); // Completing out of the app and deleting exported video file try { exportedVideoPlayerWindow.Close(); MainWindow.Close(); } catch {} ShellExecute(@"cmd /c taskkill /f /im ApplicationFrameHost.ex*",timeout:globalFunctionTimeoutInSeconds,forceKillOnExit:true,waitForProcessEnd:true); // Close out of the Photos app Wait(globalIntermittentWaitInSeconds); File.Delete($"{temp}\\LoginPI\\myVideo.mp4"); } }