Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Change Monitor Input Source

  • Please log in to reply
21 replies to this topic
  • Members
  • 868 posts
  • Last active: Jan 25 2016 01:29 AM
  • Joined: 04 Mar 2013

I'm not familiar with mControl, all the script above does is set your 'Input Source' on the VCP table of your monitor to a certain value, I've determined that my monitor inputs correspond to :

  • DVI = 3
  • HDMI = 4
  • YPbPr = 12

Currently I've not be able to get the script to fully work, it will change my source to YPbPr but my monitor thinks there is no input to the device, and I've not look at the script again since my last post.  Due to the spotty support of VESA Monitor Command Control Set or MCCS I can't be sure if the monitor is not working as it should or if I need additional code.


If anyone has gotten this to work I'd appreciate it if they would comment so we know the code can work, I'd say if it works for no one the code needs more work(likely:)).

My script runs in A_AhkVersion:=, get the latest version at http://ahkscript.org/download/

Check out this AutoHotkey tutorial: http://ahkscript.git...o/AHK_Tutorial/

Read the documentation: http://ahkscript.org.../AutoHotkey.htm

  • Members
  • 1 posts
  • Last active: Feb 10 2014 11:50 PM
  • Joined: 25 Dec 2013

Interesting. For the 4 basic display setups (Monitor 1, Monitor 2, Duplicate, Extend) I've always just used, respectively:

Run, displayswitch.exe /internal
Run, displayswitch.exe /external
Run, displayswitch.exe /clone
Run, displayswitch.exe /extend

It's great to use DLLs though, when you don't want to technically be running extra processes!

  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

I don't know under what conditions GetNumberOfPhysicalMonitorsFromHMONITOR returns more than 1, 


Now I do: when displays are set to duplicate.



Using VCP code 0xd6, with in my case a set of {1, 4, 5} values, I was able to turn on, standby or turn off my monitor.


That didn't work with my BenQ GL2450HM.  According to the MCCS standard, 5 is functionally equivalent to turning off power using the “power button”.  That works for me.  None of the other values work.  So basically, I can turn my monitor off programmatically, but can't turn it back on without physically pressing the button.


Also, as a dual screen user, multi monitor support would be nice. I don't know if that is hard to implement, because I'm just now starting to look into it.


If you have extended desktop enabled, you can get a different HMONITOR by calling MonitorFromPoint with the appropriate coordinates.  Otherwise I suppose you could use EnumDisplayMonitors.

  • Members
  • 1228 posts
  • Last active: Apr 08 2017 06:17 PM
  • Joined: 29 May 2006
typedef enum _MC_COLOR_TEMPERATURE {

Something like this doesn't work though:

, "int", handle
, "float*", test)

msgbox % test

I'm hopping someone with an understanding of dllcall can help out.




I believe this is how it's meant to work, but my two monitors only report three supported colour temperatures.....

e := DllCall("Dxva2.dll\GetMonitorCapabilities"
		, "Ptr", hPhysicalMonitor
		, "Int*", pdwMonitorCapabilities 
		, "Int*", pdwSupportedColorTemperatures)

capabilities := ""
for ID, value in aMonitorCapabilities := { MC_CAPS_NONE: 0x00000000
					                     , MC_CAPS_MONITOR_TECHNOLOGY_TYPE: 0x00000001
					                     , MC_CAPS_BRIGHTNESS: 0x00000002
					                     , MC_CAPS_CONTRAST: 0x00000004
					                     , MC_CAPS_COLOR_TEMPERATURE: 0x00000008
					                     , MC_CAPS_RED_GREEN_BLUE_GAIN: 0x00000010
					                     , MC_CAPS_RED_GREEN_BLUE_DRIVE: 0x00000020
					                     , MC_CAPS_DEGAUSS: 0x00000040
					                     , MC_CAPS_DISPLAY_AREA_POSITION: 0x00000080
					                     , MC_CAPS_DISPLAY_AREA_SIZE: 0x00000100
					                     , MC_CAPS_RESTORE_FACTORY_DEFAULTS: 0x00000400
					                     , MC_CAPS_RESTORE_FACTORY_COLOR_DEFAULTS: 0x00000800
					                     , MC_RESTORE_FACTORY_DEFAULTS_ENABLES_MONITOR_SETTINGS: 0x00001000}
	if (pdwMonitorCapabilities & value)
		capabilities .= "`n" ID

supportedColours := ""
for ID, value in aMonitorSupportedColourTemperatures := { MC_SUPPORTED_COLOR_TEMPERATURE_NONE: 0x00000000
									,    MC_SUPPORTED_COLOR_TEMPERATURE_4000K: 0x00000001
									,    MC_SUPPORTED_COLOR_TEMPERATURE_5000K: 0x00000002
									,    MC_SUPPORTED_COLOR_TEMPERATURE_6500K: 0x00000004
									,    MC_SUPPORTED_COLOR_TEMPERATURE_7500K: 0x00000008
									,    MC_SUPPORTED_COLOR_TEMPERATURE_8200K: 0x00000010
									,    MC_SUPPORTED_COLOR_TEMPERATURE_9300K: 0x00000020
									,    MC_SUPPORTED_COLOR_TEMPERATURE_10000K: 0x00000040
									,    MC_SUPPORTED_COLOR_TEMPERATURE_11500K: 0x00000080 }
	if (pdwSupportedColorTemperatures & value)
		supportedColours .= "`n" ID

msgbox % capabilities "`n`n========================`n" supportedColours

  • Members
  • 1 posts
  • Last active: May 22 2014 12:11 PM
  • Joined: 14 May 2014



i have been trying out the Script for Switching the input source on a Fujitsu B24T-7. First I tried to figure out the values for the different input sources using getMonitorInputSource()


I got the following


VGA = 1

DVI = 3

HDMI = 0 (which is odd i guess)


Switching between VGA and DVI works fine, but i can't get it to Switch from DVI or VGA to HDMI or the other way round. As you might expect i have pretty much zero experience in DDC/CI (or programming in general).


I wanted to ask if anybody has stumbled upon a similiar problem and maybe found a fix for it?


best regards



  • Members
  • 1 posts
  • Last active: Jul 17 2014 03:59 PM
  • Joined: 17 Jul 2014

I made it work for me with very slight modification. 

I'm using extended desktop with 2 gpus plugged to same BenQ E2220HD, one using DVI and other HDMI port. At first I tried reading values for input sources using getMonitorInputSource(). I got 17 for primary display(HDMI) and 0 for other. I used setMonitorInputSource(0) but monitor just went black for a moment like while normally changing source but went back to the primary. I tried changing source through softMCCS and it worked properly. I scooped over softMCCS logs and found out that even though getMonitorInputSource() returned 0 for DVI source softMCCS used 03 while changing to that source( write 03 60 00 03 ). After that I looked for write executed by softMCCS for switching to HDMI but value was the same - 17. setMonitorInputSource(3) worked but I couldn't switch back to primary, I've figured that the case was incorrect handle and modified code to use handle based on mouse position. Now it's working as intended for me.



; Finds monitor handle based on MousePosition
  MouseGetPos, xpos, ypos
  point := ( ( xpos ) & 0xFFFFFFFF ) | ( ( ypos ) << 32 )
  ; Initialize Monitor handle
  hMon := DllCall("MonitorFromPoint"
    , "int64", point ; point on monitor
    , "uint", 1) ; flag to return primary monitor on failure

  ; Get Physical Monitor from handle
  VarSetCapacity(Physical_Monitor, 8 + 256, 0)

    , "int", hMon   ; monitor handle
    , "uint", 1   ; monitor array size
    , "int", &Physical_Monitor)   ; point to array with monitor

  return hPhysMon := NumGet(Physical_Monitor)

  DllCall("dxva2\DestroyPhysicalMonitor", "int", handle)

; Used to change the monitor source
; DVI = 3
; HDMI = 4
; YPbPr = 12
  handle := getMonitorHandle()
    , "int", handle
    , "char", 0x60 ;VCP code for Input Source Select
    , "uint", source)

; Gets Monitor source
  handle := getMonitorHandle()
    , "int", handle
    , "char", 0x60 ;VCP code for Input Source Select
    , "Ptr", 0
    , "uint*", currentValue
    , "uint*", maximumValue)
  return currentValue

; Switching sources~
if(getMonitorInputSource() > 3)

  • New members
  • 1 posts
  • Last active: Aug 22 2015 09:48 PM
  • Joined: 20 Aug 2015

I can get the code above to work on a monitor that I have both inputs connected to the computer I am sending commands from.  However what I am trying to do is switch from my computer to a console, and then from the console back to the computer.  with the code provided, I can get the computer to switch to the console input, but it seems that once I am no longer on an input that is hooked up to the computer it doesn't accept commands from the computer.  Any help would be greatly appreciated!