Hey everyone! I'm looking for some help on automating my PC display settings when switching between using it as a monitor and a TV via HDMI. Currently, I have my PC connected to a monitor with VGA and to a TV with HDMI. The problem is that when I switch from the monitor to the TV, the display configuration can get tedious to change manually, especially since both screens have different resolutions. I'd like to set up a script that changes these configurations automatically based on whether an HDMI signal is present. Is there a way to create an event in Windows that detects when the HDMI connection is established or disconnected and triggers my PowerShell script accordingly? Any advice would be greatly appreciated!
4 Answers
You can definitely use Windows Task Scheduler if you find an event in the event logs that corresponds to your HDMI connection changes. This way, whenever that event is logged, the task would trigger and run your .ps1 script automatically.
If you're checking for events, you're in luck! If Windows logs the HDMI device change, you should be able to use that to trigger actions. Also, consider using a tool like MultiMonitorTool to simplify the whole process. It can handle those changes for you without much hassle.
Short answer: it's challenging. Long answer: while it's possible, it might involve some programming with WMI. If you can find existing event logs that capture device changes, you could set up notifications for those. Still, the underlying issue might be your display settings not saving properly, which could be worth troubleshooting instead.
Yeah, definitely check if your settings are saving correctly. That might save you a lot of work!
You might want to look into tools like DisplayFusion as they can simplify multi-monitor setups. However, if you're keen on using PowerShell, try monitoring the audio device changes since connecting the TV via HDMI typically adds an audio device. That could help in automating resolution adjustments too.
I implemented something similar at a company for monitoring network connections. It worked flawlessly for years!