-
Notifications
You must be signed in to change notification settings - Fork 71
/
CornerNotify.ahk
87 lines (73 loc) · 2.93 KB
/
CornerNotify.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
;---------------------------------------------------------------
; CornerNotify.ahk
; http://www.autohotkey.com/board/topic/94458-msgbox-replacement-monolog-non-modal-transparent-message-box-cornernotify/
;---------------------------------------------------------------
; CHANGELOG
; v1.1 2013-06-19
; added optional position argument that calls WinMove function from user "Learning One"
; position argument syntax is to create a string containing the following:
; t=top, vc= vertical center, b=bottom
; l=left, hc=horizontal center, r=right
;---------------------------------------------------------------
CornerNotify(secs, title, message, position="b r") {
CornerNotify_Create(title, message, position)
millisec := secs*1000*-1
SetTimer, CornerNotifyBeginFadeOut, %millisec%
}
CornerNotify_Create(title, message, position="b r") {
global cornernotify_title, cornernotify_msg, w, curtransp, cornernotify_hwnd
CornerNotify_Destroy() ; make sure an old instance isn't still running or fading out
Gui,+AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
cornernotify_hwnd := WinExist()
WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT make the window transparent-to-mouse
WinSet, Transparent, 160
curtransp := 160
Gui,Color, 202020 ;background color
Gui,Font, c5C5CF0 s17 wbold, Arial
Gui,Add, Text, x20 y12 w668 vcornernotify_title, %title%
Gui,Font, cF0F0F0 s15 wnorm
Gui,Add, Text, x20 y56 w668 vcornernotify_msg, %message%
Gui,Show, NoActivate W700
WinMove(cornernotify_hwnd, position)
Return
}
CornerNotify_ModifyTitle(title) {
global cornernotify_title
GuiControl,Text,cornernotify_title, %title%
}
CornerNotify_ModifyMessage(message) {
global cornernotify_msg
GuiControl,Text,cornernotify_msg, %message%
}
CornerNotify_Destroy() {
global curtransp
curtransp := 0
Gui, Destroy
SetTimer, CornerNotify_FadeOut_Destroy, Off
}
CornerNotifyBeginFadeOut:
SetTimer, CornerNotifyBeginFadeOut, Off
SetTimer, CornerNotify_FadeOut_Destroy, 10
Return
CornerNotify_FadeOut_Destroy:
If(curtransp > 0) {
curtransp := curtransp - 4
WinSet, Transparent, %curtransp%, ahk_id %cornernotify_hwnd%
} Else {
Gui, Destroy
SetTimer, CornerNotify_FadeOut_Destroy, Off
}
Return
;---------------------------------------------------------------
; Modification of WinMove function by Learning One (http://www.autohotkey.com/board/topic/72630-gui-bottom-right/#entry461385)
; position argument syntax is to create a string with the following:
; t=top, vc= vertical center, b=bottom
; l=left, hc=horizontal center, r=right
WinMove(hwnd,position) { ; by Learning one
SysGet, Mon, MonitorWorkArea
WinGetPos,ix,iy,w,h, ahk_id %hwnd%
x := InStr(position,"l") ? MonLeft : InStr(position,"hc") ? (MonRight-w)/2 : InStr(position,"r") ? MonRight - w : ix
y := InStr(position,"t") ? MonTop : InStr(position,"vc") ? (MonBottom-h)/2 : InStr(position,"b") ? MonBottom - h : iy
WinMove, ahk_id %hwnd%,,x,y
}
;---------------------------------------------------------------