Switch Second Monitor Input Source

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
lightning
Posts: 1
Joined: 24 Sep 2018, 03:43

Switch Second Monitor Input Source

24 Sep 2018, 03:50

Hi there, I have two monitors connected to one pc; my second monitor is also connected to another pc using dvi.
I have a script which switch my monitor source from dvi to vga. But this script only switch my first monitor. I want to switch my second monitor input source. What should I do?

Code: Select all

; 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 = 1
; DVI = 3
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
if(getMonitorInputSource() = 02)
  setMonitorInputSource(01)
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: -Garfle-, Draken, Google [Bot], gsxr1300, HiSoKa and 261 guests