-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSplash Tooltip.ahk
67 lines (46 loc) · 1.46 KB
/
Splash Tooltip.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
/*
Shows a tooltip for a predefined amount of time, after which, it will auto-hide
Usage:
new SplashTooltip(timeout, x="", y="", whichToolTip="")
timeout
Time in miliseconds after which the tooltip will hide itself
x, y, whichToolTip
The arguments for the ToolTip command
https://www.autohotkey.com/docs/commands/ToolTip.htm
SplashTooltip.show(text)
text
The text to appear on the tooltip
Example:
; This will show a tooltip for 2 seconds, then disappears for 2 seconds, and finally show another tooltip for 2 seconds
stp := new SplashTooltip(2000)
stp.show("abcd")
Sleep, 4000
stp.show("efgh")
*/
class SplashTooltip {
state := 0
__New(timeout, x="", y="", whichToolTip="") {
this.timeout := timeout * -1
this.x := x
this.y := y
this.whichToolTip := whichToolTip
this.__hide := ObjBindMethod(this, "hide") ; Required because of the limitation of SetTimer
}
__Delete() {
this.hide()
}
show(text) {
__hide := this.__hide ; SetTimer requires a plain variable reference
if this.state
SetTimer, % __hide, Delete
ToolTip, % text, this.x, this.y, this.whichToolTip
SetTimer, % __hide, % this.timeout
this.state := 1
}
hide() {
__hide := this.__hide ; SetTimer requires a plain variable reference
ToolTip,,,, this.whichToolTip
SetTimer, % __hide, Delete
this.state := 0
}
}