How to set monitor input source (VGA, DVI, HDMI) from command line on Windows operating system

The ControlMyMonitor utility allows you to change the settings of your monitor from command-line and GUI.
In order to use this tool to set the desired input source (VGA, DVI, HDMI) from command-line, you have to switch your monitor to the desired input source, run the ControlMyMonitor utility and in the main window, look at the line with VCP Code 60 (Input Select). The 'Current Value' column shows the number of the active input source.

Here's an example for command tp set the desired input source:
ControlMyMonitor.exe /SetValue "\\.\DISPLAY2\Monitor0" 60 3

In the above example - the "\\.\DISPLAY2\Monitor0" is the monitor name. You can also use the monitor ID or serial number of the monitor. The '3' value is number of the input source.

If you want to change the input source of the primary monitor, you can simply use the 'Primary' string instead of monitor name, for example:
ControlMyMonitor.exe /SetValue Primary 60 1

Be aware that ControlMyMonitor will work on your system only if your hardware supports DDC/CI, and you have Windows Vista or later version of Windows (Including Windows 10). Windows XP is not supported.