Skip to main content
InSource Solutions

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.

clipboard_ec37c7e4c4eaac6672abfe43df5b85f8d.png

 

Once the symbol is created , open the symbol editor by right clicking and selecting Open or simply double clicking on the symbol. 

clipboard_e194a69e2cf007ab94290784ef3c030ab.png

 

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.

clipboard_e5b546df163998e095acb33de0caba938.png

Double click the Single Instance button and give it an Action Script Animation

clipboard_e1be84364d243710a30d8d8af2629d519.png
 

Paste the script below in the script editor and select OK.

dim wProcess as System.Diagnostics.Process;
wProcess = System.Diagnostics.Process.GetCurrentProcess();
wProcess.CloseMainWindow();

clipboard_e93d382c25dd14ecf88f31bd33575e9a1.png

 

Double click the Multi Instance button and give it an Action Script Animation.

clipboard_e845f5c4e35ecd52f24ab12801cebc034.png

 

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;

clipboard_ea5b80246ea1072e14adc57fc7e1809bc.png

 

Save and Close the Symbol Editor.

clipboard_e3b15535d4d507729140f666b28094f17.png

 

Check in the object.

clipboard_e274dd6c629196c492cb6d0ff6a4cc484.png

 

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. 

clipboard_e09cac58adda1b846c99eba389fa369a5.png

 

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). 

clipboard_e0d9887ab8d21a4b4437df5e2e5fced82.png

 

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.

clipboard_e2d36b95f29a045355a4cf6f6d110c0e7.png

  • Was this article helpful?