I started off by looking at ways I could change the monitor inputs, I came across a tool called ControlMyMonitor, using this you can identify cmd prompts that will control your monitor, you can change Brightness, Contrast as well as Input Select and a whole host of other parameters.
Having played around with the Input Select values I determined that:
15 = Display Port
17 = HDMI
I could then write this into a script I could run in cmd prompt.
"C:\Program Files (x86)\ControlMyMonitor\ControlMyMonitor.exe" /SetValue "\\.\DISPLAY1\Monitor0" 60 15"
"C:\Program Files (x86)\ControlMyMonitor\ControlMyMonitor.exe" /SetValue "\\.\DISPLAY1\Monitor0" 60 17"
Bingo.... Monitor now switches between inputs.
Next onto the Logitech devices, I have an MX Keys and a MX Master 2S.
hidapitester was the software I found for doing this, like with the Montior solution this allows you to write scripts in cmd prompt sending comands to the Logitech unifying receiver to switch between profiles on both the mouse and KB.
I started out trying to determine the hex code required for this by using software called busdog, this allows you to monitor traffic and decode it from USB ports. After hours trying to find the correct code I gave up and reverted to google.
There I found some examples of what other had done but non worked straight away for me but after some trial and error I came up with prompts that worked.
First off you need the VIDPID address of the receiver, it seems that this is the same for all unifying receivers. It's easily found in device manager.
Next was this portion to send the command
--usage 1 --usagePage 0xFF00 --open --length 7 --send-output
Then comes the Hexadecimal
The ones to focus on here are 2nd and 5th. Here the 2nd is the device ID, it seems to be dependant on the order in which you connected your devices. On one PC 0x01 was my mouse on the other it was my keyboard.
That ment on PC one 0x02 would speak to my keyboard.
The 5th section corresponds to the input select.
- 0x00 - Input 1
- 0x01 - Input 2
- 0x02 - Input 3
So put it all together and...
1st Device (Mouse) "C:\Program Files (x86)\hidapitester\hidapitester.exe" --vidpid 046D:C52B --usage 1 --usagePage 0xFF00 --open --length 7 --send-output 0x10,0x01,0x09,0x1c,0x00,0x00,0x00 2nd Device (Keyboard) "C:\Program Files (x86)\hidapitester\hidapitester.exe" --vidpid 046D:C52B --usage 1 --usagePage 0xFF00 --open --length 7 --send-output 0x10,0x02,0x09,0x1c,0x00,0x00,0x00
Putting it all together