← All writing

I finally built the KVM switch I gave up on in 2020

One button now switches my keyboard and all three monitors between two PCs, thanks to AutoHotkey, monitor serial numbers, and an evening with AI.

  • automation
  • ai
  • hardware
  • autohotkey

For years my desk has been a small daily annoyance. I have two computers, one for home and one for work, sharing three monitors, and a $20 USB switch for the keyboard. Every time I changed computers, I pressed the USB button and then reached behind three monitors to cycle through their input menus one at a time. Back in 2020 I tried to fix it: I found NirSoft’s ControlMyMonitor, which can change a monitor’s input from the command line, and bound it to a hotkey in AutoHotkey. It half worked. The display numbers shuffled between reboots, the Dell wanted strange values, and switching back meant a second hotkey on the other machine. Eventually I put the script in a drawer and went back to pressing buttons. Proper hardware KVMs that handle three monitors with mixed DisplayPort, HDMI and DVI cost a fortune, and the reviews made them sound flaky anyway.

This week I thought: maybe I should revisit this with AI. In one evening of back and forth, we found the problems I had never been able to pin down. My keyboard quietly reports two different USB IDs depending on how the switch hands it over. My BenQs only accept commands from whichever PC they are currently showing. And my work PC calls all three monitors “Generic PnP Monitor”. The popular open-source tool for this, display-switch, couldn’t cope with that combination. So we went back to my original idea and made it smarter. Each PC runs a small AutoHotkey script that watches for the keyboard. When the keyboard leaves a PC, that PC sends every monitor to the other one, addressing each monitor by serial number. Now I press one button and all three monitors follow. The script and setup notes are on GitHub at 0l0-app/usb-kvm, in case your desk has the same problem.