-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path置顶时钟.ah2
163 lines (146 loc) · 3.7 KB
/
置顶时钟.ah2
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include <Direct2DRender>
monitor_info := get_all_monitor_info()
g_all_clock := []
loop(monitor_info.Length)
{
g_all_clock.Push(Clock(monitor_info[A_Index]))
}
g_font_size := 30
g_opacity := 0xBB
#HotIf is_hover()
wheeldown::
{
global g_opacity
g_opacity := (g_opacity-10 < 1 ? 1 : g_opacity-10)
return
}
wheelup::
{
global g_opacity
g_opacity := (g_opacity+10 > 255 ? 255 : g_opacity+10)
return
}
^wheeldown::
{
global g_font_size
g_font_size := (g_font_size-1 < 1 ? 1 : g_font_size-1)
}
^wheelup::
{
global g_font_size
g_font_size := (g_font_size+1 > 100 ? 100 : g_font_size+1)
}
#HotIf
class Clock
{
__New(monitor_info)
{
this.overlay := Direct2DRender(0, 0, 50, 50)
this.monitor_info := monitor_info
this.x := monitor_info.Left
this.y := monitor_info.Top
this.w := monitor_info.Right - monitor_info.Left
this.h := monitor_info.Bottom - monitor_info.Top
;设置定时器
SetTimer(ObjBindMethod(this, 'draw'), 40)
}
is_hover() => this.overlay.GetMousePos(&mx, &my)
draw()
{
uijm :=A_Hour '∶' A_Min '∶' A_Sec
wh := this.overlay.GetTextWidthHeight(uijm, g_font_size, 'Courier')
w := wh.width, h := wh.height
this.overlay.SetPosition(this.x, 0, w, h)
if (this.overlay.BeginDraw())
{
this.overlay.FillRoundedRectangle(0, 0, w, h, 5, 5, g_opacity << 24)
this.overlay.DrawText(uijm, 0, 0, g_font_size, 0xccFF0000, "Courier")
this.overlay.EndDraw()
}
}
}
is_hover()
{
for k,v in g_all_clock
{
if(v.is_hover())
return true
}
return false
}
get_all_monitor_info()
{
screen_number := GetMonitorCount()
arr_screen := []
loop(screen_number)
{
info := GetMonitorInfo(A_Index)
arr_screen.Push(info)
}
return arr_screen
}
GetMonitorCount()
{
Monitors := MDMF_Enum()
return Monitors['TotalCount']
}
GetMonitorInfo(MonitorNum)
{
Monitors := MDMF_Enum()
for k,v in Monitors
{
if(IsObject(v) && v.HasOwnProp('num'))
{
if (v.Num = MonitorNum)
{
return v
}
}
}
}
GetPrimaryMonitor()
{
Monitors := MDMF_Enum()
for k,v in Monitors {
if (v.Primary) {
return v.Num
}
}
}
MDMF_Enum(HMON := "") {
static EnumProc := CallbackCreate(MDMF_EnumProc)
static Monitors := Map()
if (HMON = "") { ; new enumeration
Monitors := Map("TotalCount", 0)
if !DllCall("User32.dll\EnumDisplayMonitors", "Ptr", 0, "Ptr", 0, "Ptr", EnumProc, "Ptr", ObjPtr(Monitors), "Int")
return False
}
return (HMON = "") ? Monitors : Monitors.HasKey(HMON) ? Monitors[HMON] : False
}
MDMF_EnumProc(HMON, HDC, PRECT, ObjectAddr) {
Monitors := ObjFromPtrAddRef(ObjectAddr)
Monitors[HMON] := MDMF_GetInfo(HMON)
Monitors["TotalCount"]++
if (Monitors[HMON].Primary) {
Monitors["Primary"] := HMON
}
return true
}
MDMF_GetInfo(HMON) {
MIEX := Buffer(40 + (32 << !!1))
NumPut("UInt", MIEX.Size, MIEX, 0)
if DllCall("User32.dll\GetMonitorInfo", "Ptr", HMON, "Ptr", MIEX.Ptr, "Int") {
return {Name: (Name := StrGet(MIEX.Ptr + 40, 32)) ; CCHDEVICENAME = 32
, Num: RegExReplace(Name, ".*(\d+)$", "$1")
, Left: NumGet(MIEX, 4, "Int") ; display rectangle
, Top: NumGet(MIEX, 8, "Int") ; "
, Right: NumGet(MIEX, 12, "Int") ; "
, Bottom: NumGet(MIEX, 16, "Int") ; "
, WALeft: NumGet(MIEX, 20, "Int") ; work area
, WATop: NumGet(MIEX, 24, "Int") ; "
, WARight: NumGet(MIEX, 28, "Int") ; "
, WABottom: NumGet(MIEX, 32, "Int") ; "
, Primary: NumGet(MIEX, 36, "UInt")} ; contains a non-zero value for the primary monitor.
}
return False
}