Question / Help How to set "Window Capture" to hide when window is minimized?

ptr0x

New Member
I'm trying to set up a scene with possible applications I could open on my stream, so I set up a Window Capture for each of these applicatoins.
The problem is that each of those Window Capture will become visible when the programs starts, even when the program is minimized it will shows up on the stream.
I see it could work using "Game Capture", however I can't find the main program I want to stream (visual studio 2019) on the list of possible processes to set up a Game Capture.
Is it possible to do what I want using Window Capture? Any other ideas how to circumvent this problem?
Thanks in advance.
 

Sukiyucky

Member
Not without programming. You would need to create an application that would spin around monitoring the window state of the window you are capturing. If the window state is non-minimized, you would send a hotkey sequence to Windows that correlates with what hotkey sequence you set in OBS Hotkeys.

If you don't know how to program Windows or would like to learn, best approach would be to use AutoHotKey. Granted, this is not how we create Microsoft Windows applications. AutoHotKey is a scripting tool that can be used in cases like this.
 

xantyleonhart

New Member
This script enables or disables the capture source whenever it gains or loses focus:

It uses Xlib so it just works on linux. You might have to edit it to use another library instead.
Can also be edited to swap scenes instead of enabling/disabling the source.

PS: I don't like the idea of directly enabling or disabling it. I actually wanted to programatically launchg the "activate/deactivate" event that fires whenever you click on the "eye" icon in OBS. But i'm not familiar enough with the API to know how to do that.
 

xantyleonhart

New Member
P.S 2: Welp, i just realized this is posted under Windows Support topic, sorry for putting a linux-only script. It can be adapted though, using the win32gui package and the "GetForegroundWindow()" function.
 

sheriffoftiltover

New Member
This script enables or disables the capture source whenever it gains or loses focus:

It uses Xlib so it just works on linux. You might have to edit it to use another library instead.
Can also be edited to swap scenes instead of enabling/disabling the source.

PS: I don't like the idea of directly enabling or disabling it. I actually wanted to programatically launchg the "activate/deactivate" event that fires whenever you click on the "eye" icon in OBS. But i'm not familiar enough with the API to know how to do that.
In case anyone needs this in the future, I updated the script for windows:
https://gist.githubusercontent.com/...dd84878c2269e7a003a/hide_unfocused_windows.py
 
Top