Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launching a browser doesn't switch to that application #2

Closed
kputschko opened this issue Dec 14, 2021 · 2 comments
Closed

Launching a browser doesn't switch to that application #2

kputschko opened this issue Dec 14, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@kputschko
Copy link

Hey there, I'm loving this launcher. I'm trying to set up a button to launch a browser, and the following command successfully launches Edge, but Flex-Launcher still maintains focus after the browser is launched. Any ideas why this this happening?

Entry1=Browser;.\assets\icons\system.png; "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Edge.lnk"
@complexlogic complexlogic added bug Something isn't working and removed bug Something isn't working labels Dec 15, 2021
@complexlogic
Copy link
Owner

Flex Launcher assumes that the launched executable won't return until the user has closed the application. The problem is that the Edge executable doesn't behave the way most programs do. The msedge.exe is really just a launcher. It works by forking a new process for the browser window, and then immediately returns. Chrome and Firefox on Windows also have the same behavior. So when you launch the Edge executable, it will successfully create a browser window, but Flex Launcher will re-grab the window focus almost immediately after, mistakenly thinking that Edge has closed.

As a workaround, you can use the following script to block until Edge has closed. Change the path to the msedge.exe if necessary.

@echo off
start "msedge" "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"

:loop
tasklist /FI "ImageName eq msedge.exe"  | find /i "msedge" > nul || goto :done
timeout /t 2 >nul
goto :loop

:done

It works by checking every 2 seconds to see if there are any Edge processes running, and it won't return until there are none.

Paste it into a .bat file, and then you can structure your menu entry like so:

Entry1=Browser;.\assets\icons\system.png;"C:\path\to\scripts\launch_edge.bat"

Eventually, I will incorporate similar logic into Flex Launcher itself, but you may use this workaround for the time being.

@complexlogic
Copy link
Owner

This issue is fixed in the latest release, v1.3. The logic from the above script is now incorporated directly into the launcher. Upon program launch, the launcher will check the image name of the resulting process, and, if it matches chrome.exe, msedge.exe, or firefox.exe, then it will wait until all processes of the same name have terminated before returning to the launcher screen. Launching a web browser via a shortcut to it's .exe is allowable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants