Tip: Switch Monitor Inputs with Command Line


I quickly grew tired of manually switching inputs using my monitor’s soft switches. Instead, I found a application that allows me to make the switch using a command line. Skip ahead to The Solution or read on for details…

The Scenario

I share two 27″-4K (Viewsonic VP2780-4K) monitors between two PCs in my home office. One of the PCs is a desktop with dual DisplayPort outputs. The other is my client’s Lenovo laptop that currently has one HDMI output and one DisplayPort (using a DisplayLink USB 3.0 to DisplayPort adapter).

I switch from my desktop PC to my client’s laptop at least once each day, and sometimes more often.

I looked into using a dual-head KVM switch to make it easier to share monitors with multiple PCs, but the options for switching 4K resolution using DisplayPort inputs are somewhat limited. Additionally, the laptop doesn’t support dual DisplayPort outputs due to its modest graphics processing capabilities.

I eventually decided to forego a one-stop switching solution and use a simple USB 2.0 Switch for keyboard and mouse. For displays, I realized I would have to take advantage of the fact that my monitors support multiple inputs (1 x DisplayPort, 1 x Mini DisplayPort, and 3 x HDMI).

Switching between PCs involves these steps:

  1. Press physical button on USB Switch to flip keyboard and mouse
  2. Manually switch Monitor 1 from laptop to desktop (or vice versa)
  3. Manually switch Monitor 2 from laptop to desktop (or vice versa)

This is not ideal – it’s even a step back from many years ago when I had a KVM switch that I could operate by double-tapping my NUMLOCK key. But since I only switch about once per day, it’s acceptable.

The Problem

The problem is with my monitors. There are 5 soft key buttons (1, 2, down, up, and power). But the buttons are completely flat and non-tactile. In other words, I can not feel anything when I activate the buttons – they are part of the bezel. To make matters even worse, they are not backlighted and the labels on the buttons are a dark gray (on a back bezel background).

Needless to say, it’s VERY hard to accurately make the 3 button presses it takes to switch inputs on the monitor. More often than not, I end up fumbling to find the first button (for accessing the menu). And then I often press the wrong arrow direction, which takes even more key presses to fix.

There has to be a better way!

The Solution

A little bit of research uncovered a protocol called Data Display Channel that allows graphics adapters to communicate with the monitor. This can be used to control things like colors, brightness, and even change inputs. It’s been around for quite a while and it turns out that my graphics cards and monitors all have what it takes.

A bit more research uncovered a freeware utility from NirSoft called ControlMyMonitor (currently version 1.11). After downloading and running it, I quickly discovered that it could view and modify all of my monitor’s settings:ControlMyMonitor1

Notice the selected row in the screenshot above – VPC Code 60 is the “Input Select” control, which controls the monitor’s input. This may be different depending on your graphics card and monitor.

I verified that I could change inputs by changing this setting between the possible values that you see in the right-most column (15-19, in this case). A little bit of trial and error indicated which value I needed to change in order to switch the monitor from my desktop to laptop.

The help file that came with ControlMyMonitor includes instructions for how to apply setting changes using Command Line.

Here are the steps I used:

    1. Determine the monitor’s identification strings. You can find these inside ControlMyMonitor (Edit | Copy Monitor Strings). Any one of these will be needed by the command line – and the one you use must be unique. If you have two identical monitors then you’ll need to use something like Serial Number instead of Monitor Name.
    2. Determine the VCP Code corresponding to your monitor’s Input Select function. I’m not sure if these are consistent between systems – mine is 60.
    3. Determine the value corresponding to the input you’d like to set. I used trial and error. I’m not sure if there’s a more precise way to know which input corresponds to which value, unless your monitor has this documented somewhere.
    4. Create a shortcut with the following syntax:
      ControlMyMonitor.exe /SetValue [YourMonitorString] [VCP Code] [Value]

      My string looks like this:

      ControlMyMonitor.exe /SetValue "\\.\DISPLAY1\Monitor0" 60 15
    5. For good measure, I created a shortcut with this command so I can double-click it. You can get fancy and pin it to your Start Menu or Taskbar. Since I have a ShuttleXpress connected to my desktop, I also assigned this command to one of its keys for even faster access.

One BIG caveat about changing inputs using ControlMyMonitor: This can only be used by the computer that is CURRENTLY displaying to the monitor! After I change the input from my desktop to my laptop, my desktop can no longer see that monitor! I have to perform the same process with ControlMyMonitor from my laptop in order to avoid manually switching as before.

Despite this small caveat, this is my finally process for switching between PCs:

  1. Activate the ControlMyMonitor shortcut to switch the monitor (or monitors, if I decided to switch both at the same time)
  2. Press the physical button to switch the Keyboard and Mouse

This is MUCH better than feeling like you have cartoonishly-large hands while fumbling around with the monitor’s soft keys!

Wreck-It Ralph