flex-launcher icon indicating copy to clipboard operation
flex-launcher copied to clipboard

Windows Apps on Close

Open jocko96b opened this issue 1 year ago • 2 comments

I have added Windows apps to the launcher (not an easy feat, Windows apps are...special). However, when closing some apps, say Disney+, flex-launcher returns to a black screen.

Environment: OS: Windows 11 Home 23H2 Test Resource: Disney+ app installed from the Windows app store.

Steps to reproduce:

  1. Press the Windows Key + R to open the run dialog window and execute the following command: shell:AppsFolder
  2. Right click on the Disney+ app, and select Create Shortcut.
  3. Acknowledge the error that a shortcut cannot be placed in this folder, and accept putting the shortcut on the Desktop.
  4. Edit the flex-launcher config.ini to add the Disney app using the previously created shortcut (along with an app icon).
  5. Launch flex-launcher and select the newly created Disney icon.
  6. Close the Disney Windows app.
  7. Result: a. Expected result: Disney app closes, flex-launcher appears and is usable to open other apps. b. Observed result: Disney app closes, flex-launcher is a black screen and non-interactive (but not reported by Windows as unresponsive) .

The Amazon Prime Video app (found in C:\program files\Applications\ actually uses a .exe file to launch, so that works fine. Netflix and Disney use some kind of special Windows App magic to launch the app, but Netflix allows you to run a batch file with the contents of "run netflix:" which can be loaded into flex-launcher, but the Disney app doesn't offer any such option.

Below is the debug output. The steps here was to launch Netflix using a bat file (described above), close it, then launch the Disney shortcut created using the above procedures. Immediately before the Key Escape entry is where the black screen is shown.

Loading menu 'Main' Begin program loop Gained keyboard focus Key Return (#D) detected Selected Entry: Title: Netflix Icon Path: C:\Users\jocko\OneDrive\Documents\flex-launcher-2.1-win64\CustomShortcuts\icons\netflix.png Command: "C:\Users\jocko\OneDrive\Documents\flex-launcher-2.1-win64\customShortcuts\startNetflix.bat" Lost keyboard focus Application detected Lost mouse focus Gained keyboard focus Application finished Key Right (#4000004F) detected Key Right (#4000004F) detected Key Return (#D) detected Selected Entry: Title: Disney+ Icon Path: C:\Users\jocko\OneDrive\Documents\flex-launcher-2.1-win64\CustomShortcuts\icons\disney.png Command: "C:\Users\jocko\OneDrive\Documents\flex-launcher-2.1-win64\customShortcuts\disney+ - shortcut.lnk" Lost keyboard focus Application detected Lost mouse focus Gained keyboard focus Key Escape (#1B) detected Quitting program

jocko96b avatar Dec 01 '23 01:12 jocko96b

In order for the launcher to consider the launched application "finished", it has to regain the window focus, and the launched process has to terminate. It appears that the first condition is being met, but not the second one.

I'm not quite sure how the process management works for Windows store apps. I designed the launcher to work with conventional WIN32 .exe programs. I'll have to do some research and see if I can come up with a solution that works for both types of programs.

complexlogic avatar Dec 01 '23 02:12 complexlogic

I finally managed to find a hacky workaround, but it requires a bit of legwork from the user to get it to work. It essentially launches Explorer to launch the Windows app, leaving Flex-Launcher to sit and watch the explorer.exe process (instead of the App) to close to then appropriately return control back to Flex-Launcher.

In case someone wants to know how (or add it as a workaround in your docs):

  1. Press the Windows Key + R to open the run dialog window and execute the following command: shell:AppsFolder

  2. Right click on the app you want to use, and select Create Shortcut.

  3. Acknowledge the error that a shortcut cannot be placed in this folder, and accept putting the shortcut on the Desktop.

  4. On the Desktop, right click on the newly created shortcut and select Properties

  5. In the Shortcut tab, record the data found in the Target Type field.

  6. Create a new batch file with the following command: explorer shell:appsfolder\Recorded Target Type

      ie: explorer shell:appsfolder\Disney.37853FC22B2CE_6rarf9sa4v8jt!app 
    
  7. Load that batch file into the config.ini

jocko96b avatar Dec 01 '23 04:12 jocko96b