Is there an event when connecting a monitor? (Scripting)

LukasTycho

New Member
Hi, I'm using OBS as a "Video Switcher" with a big screen. I'm using a Fullscreen Projector for this. I have a small script that autostarts the projector when OBS is started, which works fine if the screen is turned on. If the screen is off, it is not detected as a monitor in Windows and therefore OBS does not start the projector. Is there any way to detect when the screen is being turned on, i.e. to detect when there is a new monitor connected to the PC and use that as a trigger in a script?

My thought is that there might be an event for that for which I simply have to add a callback function, but I couldn't find any information about such an event.

Any help would be greatly appreciated. (If you wonder why I don't simply start the projector manually when connecting the screen: I'm not the only person using the system and want to keep it as simple as possible for less experienced people.)
 

marcag

New Member
I am looking for exactly the same thing! Plugging in monitors/beamers and instantly getting specific scenes projected onto them would be *SUCH* an incredible feature to have. It's impossibly hard to explain to everyone the one, "extremely specific" order, in which they have to power on all devices and softwares...

Additionally, I could make trouble shooting instantly 100000% more intuitive for people not used to OBS (plug in beamer 'a' or testmonitor 'd' and they instantly see the result).
 

LukasTycho

New Member
Unfortunately I have not found an internal obs solution, but I have a workaround that might work for you as well.

I have written a small python script that checks if a new monitor is connected, and starts the projector if a new monitor is detected. To start the projector in obs I am using the obs WebSocket and the Python Module simpleobsws. Using that you can also select a specific scene; and you can adjust the Python code so that it also checks which port the monitor is connected to, and maybe even the model or some other identifier of the monitor. I then simply put that script in the Windows Autostart, and it works like a charm.

I don't have the code on my Laptop right now, but I could post it in a few hours, if you are interested.
 

marcag

New Member
Awesome, thank you SO MUCH! I'll check it out when I am working on the project again! This is a neat workaround indeed!
 
Top