Mpv: Possible to prevent MPV from stealing focus at start in Windows 10?

Created on 10 Apr 2018  ·  8Comments  ·  Source: mpv-player/mpv

Is it possible to start mpv in windows 10 so that it doesn't steal the focus ?
I did not find anything in the docs and issues concerning this.

The use case:
Having two monitors and playing a game in full screen on one of them. Starting mpv to be shown on the second monitor steals the focus and makes the full screen game minimize.

There are some hacky ways to start programs without stealing focus like:
http://www.daveamenta.com/2013-08/powershell-start-process-without-taking-focus/
But they do not work with mpv.

feature-request win

All 8 comments

I'm not sure how mpv manages the "focus", but what I can say is that in Windows 10 I had many problems with the "focus" with many general applications (Photoshop, MPC HC, etc.), I do not think be a specific problem of mpv.

So like an option to start in the background, you mean?

In terms of focus, yes. But it should not conflict with other settings like making mpv topmost (--ontop).

A use case here is having a single monitor with a full screen application already running. When mpv starts topmost and without focus it plays something without breaking the workflow of the fullscreen application (losing focus while typing).

This just normal Windows behaviour, I don't think it has anything to do with mpv.
Users would probably even find it weird if it worked differently.
There are programs that start "minimised" by default though, I would honestly never expect a video player to do it, but you could try convincing devs of implementing an option to do it if you really think this is an important feature.

I'm aware that getting focus upon startup is the default behavior for programs in windows and I don't want mpvs default behavior to be changed.

What I suggest is an additional parameter (something like --no-focus ) changing the default behavior (but only if it's applied).

And starting without focus must not be mixed up with starting minimized. When starting minimized, the programs window can't be seen upon startup. When starting without focus the programs window is shown normal on top of all other windows (not to be mixed up with an always topmost window opened via --ontop ) but is not selected. Thus it doesn't steal the focus and interrupt what you are doing inside other programs the moment it shows up.

If it’s still unclear I can make a gif demonstrating what I mean by not taking focus.

There are some hacky ways to start programs without stealing focus like:
https://web.archive.org/web/20180101131314/http://www.daveamenta.com/2013-08/powershell-start-process-without-taking-focus/
But they do not work with mpv.

Oh, you're right that starting mpv with SW_SHOWNOACTIVATE should work. This looks like it could be a bug.

Hi,
I'm still interested in this functionality.

I thought about the following:
If mpv starts without a window itself and only spawns a window/graphical context when the content is ready the SW_SHOWNOACTIVATE parameter would not affect the spawned window/graphical context but only mpvs windowless process.

To be clear: I don't know IF mpv actually works like this, but if it does, this would explain why the hack fails.

mpv does currently probe VOs by creating a hidden window, but I don't think that's the problem. Seems like the problem is as simple as calling SetWindowPos to show the window when we should be calling ShowWindow (which obeys nShowCmd.) There should be a fix incoming soon.

Was this page helpful?
0 / 5 - 0 ratings