Anton Nashatyrev
Anton Nashatyrev

Reputation: 121

Install4J: tray application: soft close and restore window on launch

I have a Windows JavaFX application which minimizes to tray on Close Window button. There are actually two questions:

  1. I was trying to use Check for running processes with Soft Close option (on Upgrade and Uninstall). This action sends WINDOW_CLOSE_REQUEST to the Application as I understood. So if the Window is showing it just minimizes. If it's minimized the i4j action just doesn't send any request (it fails immediately according to logs), cause there is no any Application window. So the question is what's the best approach to signal my running application to correctly exit? (my best idea was to open a socket in app and connect it from the i4j)
  2. My launcher is of Sigle Instance App type. Are there any means to request the Application to restore from minimized state when the user executes the Application Launcher?

Thank you a lot!

Upvotes: 1

Views: 90

Answers (1)

Ingo Kegel
Ingo Kegel

Reputation: 48035

There is a hack to attach to the console of the application and send a CTRL-C event as described here:

https://stackoverflow.com/a/45754750/936832

We cannot support this in install4j because it has side effects and does not always work, but you could compile such an executable and use it in your installer.

Otherwise using a dedicated socket for shutdown is workable. Another idea is to create a file whose existence is checked periodically by the application. If the file exists, it is deleted by the application so the installer knows that the shutdown request was honored.

Upvotes: 1

Related Questions