Skip to content

Commit c30a909

Browse files
committed
修复多显示器支持问题
修复多显示器支持问题,改变获取显示器逻辑
1 parent d225945 commit c30a909

File tree

1 file changed

+46
-8
lines changed

1 file changed

+46
-8
lines changed

winautohidev2.ahk

+46-8
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ myMenu.Add("Reset all hidden windows", Reset)
3030

3131

3232
Reset(*){
33+
results := getSide()
34+
leftMonitor := results[1]
35+
leftEdge := results[3]
36+
MonitorGet leftMonitor,,&topEdge
37+
dpiValue := getDPI(leftMonitor)
3338
; 多显示器支持
34-
MonitorGet 1, &leftEdge,&topEdge
35-
monitorHandles := DPI.GetMonitorHandles()
36-
dpiValue := DPI.GetForMonitor(monitorHandles.Get(1))
37-
dpiValue := dpiValue / 120 * 125 / 100
3839
global leftEdge
3940
global dpiValue
4041
global topEdge
@@ -102,10 +103,12 @@ WatchCursor(){
102103

103104

104105
^Left::{
105-
MonitorGet 1, &leftEdge,&topEdge
106-
monitorHandles := DPI.GetMonitorHandles()
107-
dpiValue := DPI.GetForMonitor(monitorHandles.Get(1))
108-
dpiValue := dpiValue / 120 * 125 / 100
106+
results := getSide()
107+
leftMonitor := results[1]
108+
leftEdge := results[3]
109+
MonitorGet leftMonitor,,&topEdge
110+
dpiValue := getDPI(leftMonitor)
111+
; 多显示器支持
109112
global leftEdge
110113
global dpiValue
111114
global topEdge
@@ -125,6 +128,10 @@ F4::{
125128
MsgBox "Window Position: " X ", " Y "`nWindow Size: " W " x " H
126129
}
127130

131+
F8::{
132+
getSide()
133+
}
134+
128135

129136
hideWindow(id){
130137

@@ -192,3 +199,34 @@ winSmoothMove(newX,newY,window){
192199
}
193200
}
194201

202+
;多显示器支持
203+
;获取左右边界和显示器索引
204+
getSide(){
205+
leftEdge := 1
206+
rightEdge := -1
207+
leftMonitor :=0
208+
rightMonitor :=0
209+
i:=1
210+
while i<=MonitorGetCount(){
211+
MonitorGet i, &leftEdgeTemp,,&rightEdgeTemp
212+
if leftEdge > leftEdgeTemp{
213+
leftEdge := leftEdgeTemp
214+
leftMonitor := i
215+
}
216+
if rightEdge<rightEdgeTemp{
217+
rightEdge:=rightEdgeTemp
218+
rightMonitor:=i
219+
}
220+
i+=1
221+
; MsgBox(i "," leftEdgeTemp "," rightEdgeTemp)
222+
}
223+
return [leftMonitor,rightMonitor,leftEdge,rightEdge]
224+
}
225+
226+
getDPI(monitorIndex){
227+
monitorHandles := DPI.GetMonitorHandles()
228+
dpiValue := DPI.GetForMonitor(monitorHandles.Get(monitorIndex))
229+
dpiValue := dpiValue / 120 * 125 / 100
230+
return dpiValue
231+
}
232+

0 commit comments

Comments
 (0)