using LoginPI.Engine.ScriptBase; using System.Diagnostics; using System.Threading; public class libreOffice : ScriptBase { // Setting global variables int globalFunctionTimeoutInSeconds = 10; int globalIntermittentWaitInSeconds = 1; int globalCharactersPerMinuteToType = 180; 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/x0LqbseS1Dc -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 -This workload will: -Workload version and changelist: --V1.0 | original -Leave Application running compatibility: false -Recommended to read through the comments of this script to understand what it's doing and modify anything needing to be -This script will: -Open, open a document, verify has opened, navigate around inside the loaded document, and close the following apps: -LibreOffice Writer Document -LibreOffice Impress Presentation -LibreOffice Draw Drawing -LibreOffice Calc Spreadsheet -Open, verify has opened, and close the following apps: -LibreOffice application landing page -LibreOffice Math Formula -Development environmental information: -Login Enterprise scriptingtoolset version 4.2.14 -Winver 2004 OS Build 19041.508 Windows 10 Professional x64 -LibreOffice 7.0.1.2 x64 build 7cbcfc562f6eb6708b5ff7d7397325de9e764452 */ // This will download files from the appliance that will be opened by the LibreOffice applications var tempEnvironmentVariablePath = GetEnvironmentVariable("temp"); Log("Temp path is: " + tempEnvironmentVariablePath); CopyFile(KnownFiles.ExcelSheet, tempEnvironmentVariablePath + @"\loginvsi.xlsx"); CopyFile(KnownFiles.PowerPointPresentation, tempEnvironmentVariablePath + @"\loginvsi.pptx"); CopyFile(KnownFiles.WordDocument, tempEnvironmentVariablePath + @"\loginvsi.docx"); CopyFile(KnownFiles.PdfFile, tempEnvironmentVariablePath + @"\loginvsi.pdf"); // This will start the Libre Office app hub, verify it's started, then close it StartTimer("LibreOfficeAppSelectionLoadTime"); START(mainWindowTitle: "LibreOffice" , mainWindowClass:"Win32 Window:SALFRAME", processName:"soffice.bin",timeout:globalFunctionTimeoutInSeconds); MainWindow.FindControlWithXPath(xPath : "TitleBar/Button[2]",timeout:globalFunctionTimeoutInSeconds); // This finds the close button StopTimer("LibreOfficeAppSelectionLoadTime"); Wait(globalIntermittentWaitInSeconds); MainWindow.Focus(); MainWindow.Maximize(); Wait(globalIntermittentWaitInSeconds); STOP(timeout:globalFunctionTimeoutInSeconds); // This will start the LibreOffice Writer Document application with a DOCX document, verify it's started, navigate around the document, then close it StartTimer("LibreOfficeWriterStartTime"); try { string launchWriter = " " + tempEnvironmentVariablePath + @"\loginvsi.docx"; System.Diagnostics.Process.Start(@"C:\Program Files\LibreOffice\program\swriter.exe",launchWriter); } catch { ABORT("Wasn't able to start the LibreOffice Writer process. Aborting the script."); } var writerWindow = FindWindow(className : "Win32 Window:SALFRAME", title : "* - LibreOffice *", processName : "soffice.bin",timeout:globalFunctionTimeoutInSeconds); writerWindow.FindControlWithXPath(xPath : "TitleBar/Button[2]",timeout:globalFunctionTimeoutInSeconds); // This verifies the app is running by looking for the close button StopTimer("LibreOfficeWriterStartTime"); writerWindow.Focus(); Wait(globalIntermittentWaitInSeconds); Type("{esc}",cpm:globalCharactersPerMinuteToType,hideInLogging:false); // This should close welcome/tips dialog flow, if it shows writerWindow.Maximize(); Wait(globalIntermittentWaitInSeconds); Type("{PAGEDOWN}".Repeat(17),cpm:globalCharactersPerMinuteToType,hideInLogging:false); Wait(globalIntermittentWaitInSeconds); try { writerWindow.Close(); } catch { Log("Wasn't able to close the LibreOffice Writer window. It must've not been running anyway."); } Wait(globalIntermittentWaitInSeconds); // This will start the LibreOffice Impress Presentation application with a PPTX document, verify it's started, navigate around the document, then close it StartTimer("ImpressPresentationStartTime"); try { string launchPresentation = " " + tempEnvironmentVariablePath + @"\loginvsi.pptx"; System.Diagnostics.Process.Start(@"C:\Program Files\LibreOffice\program\simpress.exe",launchPresentation); } catch { ABORT("Wasn't able to start the LibreOffice Impress Presentation process. Aborting the script."); } var presentationWindow = FindWindow(className : "Win32 Window:SALFRAME", title : "* - LibreOffice *", processName : "soffice.bin",timeout:globalFunctionTimeoutInSeconds); presentationWindow.FindControlWithXPath(xPath : "TitleBar/Button[2]",timeout:globalFunctionTimeoutInSeconds); // This verifies the app is running by looking for the close button StopTimer("ImpressPresentationStartTime"); presentationWindow.Focus(); Wait(globalIntermittentWaitInSeconds); Type("{esc}",cpm:globalCharactersPerMinuteToType,hideInLogging:false); // This should close welcome/tips dialog flow, if it shows presentationWindow.Maximize(); Wait(globalIntermittentWaitInSeconds); Type("{PAGEDOWN}".Repeat(35),cpm:globalCharactersPerMinuteToType,hideInLogging:false); Wait(globalIntermittentWaitInSeconds); try { presentationWindow.Close(); } catch { Log("Wasn't able to close the LibreOffice Impress Presentation window. It must've not been running anyway."); } Wait(globalIntermittentWaitInSeconds); // This will start the LibreOffice Draw Drawing application with a PDF document, verify it's started, navigate around the document, then close it StartTimer("DrawDrawingStartTime"); try { string launchDraw = " " + tempEnvironmentVariablePath + @"\loginvsi.pdf"; System.Diagnostics.Process.Start(@"C:\Program Files\LibreOffice\program\sdraw.exe",launchDraw); } catch { ABORT("Wasn't able to start the LibreOffice Draw Drawing process. Aborting the script."); } var drawWindow = FindWindow(className : "Win32 Window:SALFRAME", title : "* - LibreOffice *", processName : "soffice.bin",timeout:globalFunctionTimeoutInSeconds); drawWindow.FindControlWithXPath(xPath : "TitleBar/Button[2]",timeout:globalFunctionTimeoutInSeconds); // This verifies the app is running by looking for the close button StopTimer("DrawDrawingStartTime"); drawWindow.Focus(); Wait(globalIntermittentWaitInSeconds); Type("{esc}",cpm:globalCharactersPerMinuteToType,hideInLogging:false); // This should close welcome/tips dialog flow, if it shows drawWindow.Maximize(); Wait(globalIntermittentWaitInSeconds); Type("{PAGEDOWN}".Repeat(5),cpm:globalCharactersPerMinuteToType,hideInLogging:false); Wait(globalIntermittentWaitInSeconds); try { drawWindow.Close(); } catch { Log("Wasn't able to close the LibreOffice Draw Drawing window. It must've not been running anyway."); } Wait(globalIntermittentWaitInSeconds); // This will start the LibreOffice Calc Spreadsheet application with an XLSX document, verify it's started, navigate around the document, then close it StartTimer("CalcSpreadsheetStartTime"); try { string launchCalc = " " + tempEnvironmentVariablePath + @"\loginvsi.xlsx"; System.Diagnostics.Process.Start(@"C:\Program Files\LibreOffice\program\scalc.exe",launchCalc); } catch { ABORT("Wasn't able to start the LibreOffice Calc Spreadsheet process. Aborting the script."); } var calcWindow = FindWindow(className : "Win32 Window:SALFRAME", title : "* - LibreOffice *", processName : "soffice.bin",timeout:globalFunctionTimeoutInSeconds); calcWindow.FindControlWithXPath(xPath : "TitleBar/Button[2]",timeout:globalFunctionTimeoutInSeconds); // This verifies the app is running by looking for the close button StopTimer("CalcSpreadsheetStartTime"); calcWindow.Focus(); Wait(globalIntermittentWaitInSeconds); Type("{esc}",cpm:globalCharactersPerMinuteToType,hideInLogging:false); // This should close welcome/tips dialog flow, if it shows calcWindow.Maximize(); Wait(globalIntermittentWaitInSeconds); Type("{PAGEDOWN}".Repeat(16),cpm:globalCharactersPerMinuteToType,hideInLogging:false); Wait(globalIntermittentWaitInSeconds); try { calcWindow.Close(); } catch { Log("Wasn't able to close the LibreOffice Calc Spreadsheet window. It must've not been running anyway."); } Wait(globalIntermittentWaitInSeconds); // This will start the LibreOffice Math Formula application, verify it's started, then close it StartTimer("MathFormulaStartTime"); try { System.Diagnostics.Process.Start(@"C:\Program Files\LibreOffice\program\smath.exe"); } catch { ABORT("Wasn't able to start the LibreOffice Math Formula process. Aborting the script."); } var mathWindow = FindWindow(className : "Win32 Window:SALFRAME", title : "* - LibreOffice *", processName : "soffice.bin",timeout:globalFunctionTimeoutInSeconds); mathWindow.FindControlWithXPath(xPath : "TitleBar/Button[2]",timeout:globalFunctionTimeoutInSeconds); // This verifies the app is running by looking for the close button StopTimer("MathFormulaStartTime"); mathWindow.Focus(); Wait(globalIntermittentWaitInSeconds); Type("{esc}",cpm:globalCharactersPerMinuteToType,hideInLogging:false); // This should close welcome/tips dialog flow, if it shows mathWindow.Maximize(); Wait(globalIntermittentWaitInSeconds); try { mathWindow.Close(); } catch { Log("Wasn't able to close the LibreOffice Math Formula window. It must've not been running anyway."); } } }