jamesmontemagno / MyStreamTimer

A cool app to count up or down that writes text to file for streamers
https://www.mystreamtimer.com
103 stars 24 forks source link

Program window steals focus when timer is activated via command line #64

Open PXAbstraction opened 2 years ago

PXAbstraction commented 2 years ago

Any time a timer is started via a command line trigger, the window steals focus. If I'm streaming a game, this swaps the game out and I have to manuall move focus back to it. Is there a way to stop having the window steal focus? This is kind of a critical function issue.

jamesmontemagno commented 2 years ago

Is this on windows or Mac?

PXAbstraction commented 2 years ago

Sorry, should have specified. This is on Windows 10.

jamesmontemagno commented 2 years ago

So, if you run it from Stream Deck or from Windows Terminal -> https://docs.microsoft.com/en-us/windows/terminal/install you shouldn't have any issues if you call

start mystreamtimer://countdown/?mins=15

That left focus on the terminal. If you run diretly from Run then it would take focus.

PXAbstraction commented 2 years ago

So I'm actually running it through my bot (MixItUp) as part of a group of commands that trigger when someone pushes certain Channel Points buttons. You can't just specify a command in the bot, it requires an actual executable file to launch, which "start" isn't recognized as since it's an in-built OS command. The way I got around this was by having the bot reference a batch file that launches My Stream Timer with the exact command you reference. The bot doesn't normally cause the app it launches to steal focus. Interestingly, the app steals focus if I run either the batch file or just the raw command from a Command Prompt.

I'll install Windows Terminal and see if I can execute it from my bot.

UPDATE: Just tried to run the command from Windows Terminal and the app still stole focus on launch.

jamesmontemagno commented 2 years ago

Would love to see what yours is doing maybe with a video recording. Here is what I see on my end

https://user-images.githubusercontent.com/1676321/155224806-58c69bd6-1e19-4cfc-9b53-9eba48d2e5b5.mp4

:

PXAbstraction commented 2 years ago

Hey there! Sorry for my delay, the last couple of days have been nuts and not left me with much time.

Here's a video showing the focus steal issue on my end.

https://user-images.githubusercontent.com/20633413/155591603-696d82de-fdde-4953-b2f5-4193a7bb7da1.mp4

Thanks!

jamesmontemagno commented 2 years ago

Hmmmmm that is extremely interesting.....

I can't reproduce it on this machine here installing from the store. Will try a few other machines... maybe it is some where flag somewhere in the registry somewhere hmmmm

PXAbstraction commented 2 years ago

Right? It's super weird. I do have a bunch of other utilities installed like DisplayFusion and the like, but nothing that normally impacts window focus. I can try this on my laptop as well and see if it happens there.

jamesmontemagno commented 2 years ago

Reached out to some friends on Twitter and I think we figured out what is going on. I will try to do a fix and get a build somehow to you to try out ;)

PXAbstraction commented 2 years ago

Oh, awesome! Not sure how test builds work with UWP apps but happy to help.

jamesmontemagno commented 2 years ago

Okay... so super weird. I can reproduce the focus issue on 1 of my profiles on this machine. And what we thought was causing the problem has no effect.... so I am trying to figure out if I have some magical setting on the other 2 profiles....

jamesmontemagno commented 2 years ago

Hmmmm one thing I could try to implement is a fake click that clicks on the app that is active

https://stackoverflow.com/questions/60575310/uwp-prevent-app-from-activating-or-taking-focus

Although things are weird because if I minimize the app and run the command it will bring it into focus on one of my profiles, but on the other 2 it leaves it minimized. hmmmm