// TARGET:outlook.exe /importprf %TEMP%\LoginPI\Outlook.prf // START_IN: ///////////// // Outlook Close // Workload: Activation-less Office Workloads // Version: 1.0.0 ///////////// using LoginPI.Engine.ScriptBase; public class Outlook_Close_Office_Activation_less : ScriptBase { // ===================================================== // Configurable Variables // ===================================================== int globalWaitInSeconds = 3; // Wait time between actions int timeoutSeconds = 2; // Timeout for window searches // ===================================================== // Execute Method // ===================================================== private void Execute() { Wait(seconds: 2, showOnScreen: true, onScreenText: "Closing Outlook if open."); Log("Closing Outlook if open."); var mainWindow = FindWindow( processName: "OUTLOOK", title: "* - Outlook*", timeout: 5, continueOnError: true ); if (mainWindow != null) { mainWindow.Focus(); mainWindow.Maximize(); Wait(globalWaitInSeconds); // Attempt to close via ALT+F4 mainWindow.Type("{ALT+F4}", hideInLogging: false); Wait(globalWaitInSeconds); // If still open, confirm via ALT+N var checkWindow = FindWindow( processName: "OUTLOOK", title: "* - Outlook*", timeout: timeoutSeconds, continueOnError: true ); if (checkWindow != null) { Wait(globalWaitInSeconds); checkWindow.Type("{ALT+N}", hideInLogging: false); Wait(globalWaitInSeconds); } } else { Log("Outlook window not found."); } } }