TN - 1209 Exiting OMI Applications Programmatically
Description
This article from InSource shows a couple script options for exiting OMI Applications.
- Author: Mario Meza
- Published:12/22/2021
- Applies to: OMI All Versions
Details
Create a Symbol in the Graphic tool box and name it whatever you like. In the example it's called ShutItDown.
Once the symbol is created , open the symbol editor by right clicking and selecting Open or simply double clicking on the symbol.
In this example two buttons were created:
- The first button for closing a single instance of OMI.
- The second for closing multiple instances of OMI.
Double click the Single Instance button and give it an Action Script Animation
Paste the script below in the script editor and select OK.
dim wProcess as System.Diagnostics.Process;
wProcess = System.Diagnostics.Process.GetCurrentProcess();
wProcess.CloseMainWindow();
Double click the Multi Instance button and give it an Action Script Animation.
Paste the script below in the script editor and select OK.
dim procArray[10] as System.Diagnostics.Process;
dim proc as System.Diagnostics.Process;
procArray = System.Diagnostics.Process.GetProcessesByName("view");
for each proc in procArray[];
proc.Kill();
next;
Save and Close the Symbol Editor.
Check in the object.
Open the OMI application and place the symbol in a layout. From here you can test the single instance button by placing the app in preview mode.
To test the buttons, from the OMI application manager open a few instances of the application. In the example four instances were launched.
The single instance button will shut down the instance from where the button was pressed (bottom left).
The Exit Multi Instance button should kill all remaining instances when pressed from any application instance.
If you happened to have more than 10 view instances you would just update the procArray[ ] to the desired number when it was first instantiated in the script.