I wasn't able to find a good topic on how to change my monitor's input source with AutoHotkey so here it is, I got a lot of help from some already posted topics:
- How to get the physical monitor handle here from Solar.
- List of VCP Control codes here i.e. the input control code is 0x60
- dxva2.dll for the functions, documentation in msdn here.
I actually used the GetVCPFeatureAndVCPFeatureReply function to see what values I would need to set the Input value to i.e.
I found for the Asus vg236 the codes where
- DVI = 3
- HDMI = 4
- YPbPr = 12
Code
; Finds monitor handle getMonitorHandle() { ; Initialize Monitor handle hMon := DllCall("MonitorFromPoint" , "int64", 0 ; point on monitor , "uint", 1) ; flag to return primary monitor on failure ; Get Physical Monitor from handle VarSetCapacity(Physical_Monitor, 8 + 256, 0) DllCall("dxva2\GetPhysicalMonitorsFromHMONITOR" , "int", hMon ; monitor handle , "uint", 1 ; monitor array size , "int", &Physical_Monitor) ; point to array with monitor return hPhysMon := NumGet(Physical_Monitor) } destroyMonitorHandle(handle) { DllCall("dxva2\DestroyPhysicalMonitor", "int", handle) } getMonitorInputSource() { handle := getMonitorHandle() DllCall("dxva2\GetVCPFeatureAndVCPFeatureReply" , "int", handle , "char", 0x60 ;VCP code for Input Source Select , "Ptr", 0 , "uint*", currentValue , "uint*", maximumValue) destroyMonitorHandle(handle) return currentValue } : Used to set the monitor source, I do not know what happens if you send it a value higher than the maximum. setMonitorInputSource(source) { handle := getMonitorHandle() DllCall("dxva2\SetVCPFeature" , "int", handle , "char", 0x60 ;VCP code for Input Source Select , "uint", source) destroyMonitorHandle(handle) } ; Msgbox with current monitor input source !r:: msgbox % getMonitorSource() return
So to set the monitor input source to HDMI I would do setMonitorSource(4), I'm sure you could pretty this up a bit all into one function.
Edit:
Here is what I ended up using:
; Finds monitor handle getMonitorHandle() { ; Initialize Monitor handle hMon := DllCall("MonitorFromPoint" , "int64", 0 ; point on monitor , "uint", 1) ; flag to return primary monitor on failure ; Get Physical Monitor from handle VarSetCapacity(Physical_Monitor, 8 + 256, 0) DllCall("dxva2\GetPhysicalMonitorsFromHMONITOR" , "int", hMon ; monitor handle , "uint", 1 ; monitor array size , "int", &Physical_Monitor) ; point to array with monitor return hPhysMon := NumGet(Physical_Monitor) } destroyMonitorHandle(handle) { DllCall("dxva2\DestroyPhysicalMonitor", "int", handle) } ; Used to change the monitor source ; DVI = 3 ; HDMI = 4 ; YPbPr = 12 setMonitorInputSource(source) { handle := getMonitorHandle() DllCall("dxva2\SetVCPFeature" , "int", handle , "char", 0x60 ;VCP code for Input Source Select , "uint", source) destroyMonitorHandle(handle) } ; Gets Monitor source getMonitorInputSource() { handle := getMonitorHandle() DllCall("dxva2\GetVCPFeatureAndVCPFeatureReply" , "int", handle , "char", 0x60 ;VCP code for Input Source Select , "Ptr", 0 , "uint*", currentValue , "uint*", maximumValue) destroyMonitorHandle(handle) return currentValue } #IfWinActive Pause:: if(getMonitorInputSource() < 2) setMonitorInputSource(3) else setMonitorInputSource(12) return
Edited by lifeweaver, 02 September 2013 - 02:29 PM.