-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMCCS.ahk
130 lines (108 loc) · 2.83 KB
/
MCCS.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
; https://autohotkey.com/board/topic/96884-change-monitor-input-source/page-2
; Finds monitor handle based on MousePosition
getMonitorHandle()
{
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)
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
}
; Gets Monitor source
getMonitorVolume()
{
handle := getMonitorHandle()
DllCall("dxva2\GetVCPFeatureAndVCPFeatureReply"
, "int", handle
, "char", 0x62 ;VCP code for Input Source Select
, "Ptr", 0
, "uint*", currentValue
, "uint*", maximumValue)
destroyMonitorHandle(handle)
return currentValue
}
; Set volume
setMonitorVolume(source)
{
handle := getMonitorHandle()
DllCall("dxva2\SetVCPFeature"
, "int", handle
, "char", 0x62 ;VCP code for Input Source Select
, "uint", source)
destroyMonitorHandle(handle)
}
; Set volume
setMonitorBrightness(source)
{
handle := getMonitorHandle()
DllCall("dxva2\SetVCPFeature"
, "int", handle
, "char", 0x10 ;VCP code for Input Source Select
, "uint", source)
destroyMonitorHandle(handle)
}
; Set volume
getMonitorCapabilities()
{
handle := getMonitorHandle()
DllCall("dxva2\GetCapabilitiesStringLength"
, "int", handle
, "uint*", lengthValue)
MsgBox, % lengthValue
VarSetCapacity(Buf,lengthValue * 2, 0)
DllCall("dxva2\CapabilitiesRequestAndCapabilitiesReply"
, "int", handle
, "Str", Buf
, "uint", lengthValue)
MsgBox, % Buf
destroyMonitorHandle(handle)
}
; getMonitorCapabilities()
; source := getMonitorVolume()
; MsgBox, % source
source := setMonitorBrightness(20)
; ; Switching sources~
; #x::
; if(getMonitorInputSource() > 3)
; setMonitorInputSource(3)
; else
; setMonitorInputSource(17)
; return