-
Notifications
You must be signed in to change notification settings - Fork 1
/
Prompt.ahk
67 lines (60 loc) · 1.84 KB
/
Prompt.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
class Prompt
{
; _backgroundColor
; _textColor
; _fontSize
; _font
; _transparency
; _centerText
__New(backgroundColor := 202020, textColor := "White", fontSize := 10, font := "Consolas", transparency := 200, centerText := true)
{
this._backgroundColor := backgroundColor
this._textColor := textColor
this._fontSize := fontSize
this._font := font
this._transparency := transparency
this._centerText := centerText
}
Prompt(text)
{
Gui, -Caption +ToolWindow +LastFound +AlwaysOnTop
Gui, Color, % this._backgroundColor
Gui, Font, % "c" this._textColor
Gui, Font, % "s" this._fontSize, % this._font
Gui, Add, Text, % this._centerText ? "+Center" : "" , % text
WinSet, Transparent, % this._transparency
Gui, Show, y0
Input, userInput, L1
Gui, Destroy
return userInput
}
; Return true if user input match
PromptMatchInput(text, match)
{
return this.Prompt(text) = match
}
; Return true if user input is space
; `n[Space to `action`] will be appended to the text
PromptMatchSpace(text, action)
{
return this.PromptMatchInput(text . "`n[Space to " . action . "]", " ")
}
Show(text)
{
Gui, New
Gui, -Caption +ToolWindow +LastFound +AlwaysOnTop +Hwndhwnd
Gui, %hwnd%:Default
Gui, Color, % this._backgroundColor
Gui, Font, % "c" this._textColor
Gui, Font, % "s" this._fontSize, % this._font
Gui, Add, Text, % this._centerText ? "+Center" : "" , % text
WinSet, Transparent, % this._transparency
Gui, Show, y0 NoActivate
callback := ObjBindMethod(this, "destroyGui", hwnd)
SetTimer, % callBack, -1000
}
destroyGui(hwnd)
{
Gui, %hwnd%:Destroy
}
}