1
1
# Requires AutoHotkey v2.0
2
2
#include Array.ahk
3
3
#include DPI.ahk
4
-
5
- ; author windwhim https://github.com/windwhim
6
4
; 实现窗口平滑移动,越小越平滑,最小为-1
7
5
SetWinDelay (5 )
8
6
@@ -25,6 +23,26 @@ global suspendWindowIds
25
23
26
24
maxHeight := 1000
27
25
26
+ ; 加入右键菜单
27
+ myMenu := A_TrayMenu
28
+ myMenu.Add()
29
+ myMenu.Add(" Reset all hidden windows" , Reset)
30
+
31
+
32
+ Reset (* ){
33
+ ; 多显示器支持
34
+ MonitorGet 1 , & leftEdge,& topEdge
35
+ monitorHandles := DPI.GetMonitorHandles()
36
+ dpiValue := DPI.GetForMonitor(monitorHandles.Get(1 ))
37
+ dpiValue := dpiValue / 120 * 125 / 100
38
+ global leftEdge
39
+ global dpiValue
40
+ global topEdge
41
+ for i,v in hiddenWindowIds{
42
+ WinMove (showMargin+ leftEdge,showMargin+ topEdge,,," ahk_id" v)
43
+ }
44
+ }
45
+
28
46
29
47
30
48
SetTimer WatchCursor, 200
@@ -36,7 +54,6 @@ WatchCursor(){
36
54
DPI.MouseGetPos , , & id , & control
37
55
; 判断是否为中间态,是则不需要移动
38
56
isSuspend := suspendWindowIds.Find((v) => (v =id ))
39
-
40
57
if isSuspend > 0 {
41
58
; 拖动窗口去除隐藏
42
59
if (isWindowMove(id )=1 ){
@@ -50,33 +67,56 @@ WatchCursor(){
50
67
}
51
68
}
52
69
else {
53
- ; 不为中间态时,判断是否为隐藏的窗口
70
+ ; 不为中间态时,则若为其他隐藏窗口则不隐藏,接着判断是否为隐藏的窗口
54
71
isHidden := hiddenWindowIds.Find((v) => (v =id ))
55
72
; 隐藏窗口则显示
56
73
if isHidden>0 {
57
74
showWindow(id )
58
75
}
59
76
else {
60
- ; 切换到其他窗口继续隐藏
77
+ ; 按顺序隐藏
61
78
if suspendWindowIds.Length > 0 {
62
- suspendId := suspendWindowIds.Get(1 )
63
- suspendWindowIds.RemoveAt(1 )
79
+ suspendId := suspendWindowIds.Get(suspendWindowIds. Length )
80
+ suspendWindowIds.RemoveAt(suspendWindowIds. Length )
64
81
hideWindow(suspendId)
65
- }
66
-
82
+ }
67
83
}
68
84
}
85
+ ; else{
86
+ ; ; 不为中间态时,则直接隐藏,接着判断是否为隐藏的窗口
87
+ ; isHidden := hiddenWindowIds.Find((v) => (v =id))
88
+ ; ; 切换到其他窗口继续隐藏
89
+ ; if suspendWindowIds.Length > 0{
90
+ ; suspendId := suspendWindowIds.Get(1)
91
+ ; suspendWindowIds.RemoveAt(1)
92
+ ; hideWindow(suspendId)
93
+ ; }
94
+ ; ; 隐藏窗口则显示
95
+ ; if isHidden>0 {
96
+ ; showWindow(id)
97
+ ; }
98
+ ; }
69
99
}
70
100
}
71
101
72
102
73
103
74
104
^Left ::{
105
+ MonitorGet 1 , & leftEdge,& topEdge
106
+ monitorHandles := DPI.GetMonitorHandles()
107
+ dpiValue := DPI.GetForMonitor(monitorHandles.Get(1 ))
108
+ dpiValue := dpiValue / 120 * 125 / 100
109
+ global leftEdge
110
+ global dpiValue
111
+ global topEdge
112
+
75
113
id := WinGetID(" A" )
76
114
hideWindow(id )
77
115
}
78
116
F4 ::{
79
117
; getWinPos
118
+ ; 多显示器支持
119
+
80
120
id := WinGetID(" A" )
81
121
window := " ahk_id" id
82
122
@@ -92,13 +132,15 @@ hideWindow(id){
92
132
; 最大化窗口不可隐藏
93
133
if WinExist (window) and WinGetMinMax(window) ! = 1 {
94
134
DPI.WinGetPos (& X, & Y, & W, & H,window)
95
- ; 乘以1.25 使用DPI缩放
96
- NewX := - Round (W* 1.25 ) + margin
135
+ ; 乘以dpi 使用DPI缩放
136
+ NewX := - Round (W* dpiValue) + leftEdge + margin
97
137
; WinMove(NewX, Y,,,window)
138
+ Y :=Max(Y,topEdge)
98
139
if H>maxHeight{
99
- WinMove (,,,H,window)
140
+ WinMove (,Y ,,H,window)
100
141
}
101
142
winSmoothMove(newX,Y,window)
143
+ WinSetExStyle " -0x80" , window
102
144
WinSetAlwaysOnTop(1 , window)
103
145
pushTo(hiddenWindowIds,id )
104
146
}
@@ -107,9 +149,10 @@ hideWindow(id){
107
149
showWindow (id ){
108
150
window := " ahk_id" id
109
151
DPI.WinGetPos (& X, & Y, & W, & H,window)
110
- NewX := showMargin
152
+ NewX := showMargin+ leftEdge
111
153
; WinMove(NewX, Y,,,window)
112
154
winSmoothMove(newX,Y,window)
155
+ WinSetExStyle " +0x80" , window
113
156
pushTo(suspendWindowIds,id )
114
157
}
115
158
isWindowMove (id ){
@@ -150,3 +193,4 @@ winSmoothMove(newX,newY,window){
150
193
WinMove (v,newY,,,window)
151
194
}
152
195
}
196
+
0 commit comments