r/usefulscripts • u/Kindly-Information52 • Sep 01 '26
[POWERSHELL] MonitorAutoSwitch - automatically moves your laptop display to the correct side of your monitor (home vs office) based on public IP
A small PowerShell tool for anyone who docks their laptop in two places with the screen on different sides.
What it does: detects your location via public IP and repositions the laptop display on the correct side (left/right) of the main monitor. Runs on logon, wake and display connect, plus a once-a-minute display-count watcher. WinForms setup wizard, system tray toggle, per-user install (no admin, lives in %LOCALAPPDATA% + Task Scheduler).
Technical notes: positions are computed from the live display widths on every run instead of stored absolute coordinates - that plus per-monitor DPI awareness (SetProcessDpiAwarenessContext) turned out to be the fix for intermittent DISP_CHANGE_FAILED (-1) errors from ChangeDisplaySettingsEx after docking.
GitHub (MIT): https://github.com/dimitrihilverda/MonitorAutoSwitch
Disclosure: written in pair-programming style with Claude. Feedback welcome.
0
20d ago
1
u/AutoModerator 20d ago
Sorry, your submission has been automatically removed.
Accounts must be at least 5 days old, which prevents the sub from filling up with bot spam.
Try posting again tomorrow or message the mods to approve your post.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/Devicode Sep 05 '26
Nice touch making it adapt automatically instead of relying on saved positions. That’s usually where setups start acting weird when you switch docks or monitors.