aboutsummaryrefslogtreecommitdiff
path: root/tt.volume.ahk
blob: 59464698ae46da1b1b414ea9fe6a809bd4d0bef9 (plain)
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
;; Volume adjustment ----------------------------------------------------------

;; -> body

XButton2::SendInput, {XButton2}
XButton2 & WheelUp::SetVolume(GetKeyState("Shift") ? 2 : 1)
XButton2 & WheelDown::SetVolume(GetKeyState("Shift") ? -2 : -1)

RAlt & F6::SetVolume(GetKeyState("Shift") ? 2 : 1)
RAlt & F5::SetVolume(GetKeyState("Shift") ? -2 : -1)

;; -> library

SetVolume(n)
{
	SoundGet, s
	s := round(s) + n
	if (s > 100)
		s := 100
	if (s < 0)
		s := 0
	SoundSet, %s%
	OSD(s)
}

/*

SetVolume(n)
{
	global wMax
	static vMin := 4
	
	SoundGet, s
	SoundGet, w, WAVE
	s := round(s)
	w := round(w)
	
	if (s > vMin or w > wMax)
		wMax := w
	else if (wMax = "")
		wMax := 100
	
	v := s + w - wMax + n
	
	if (v > 100)
		v := 100
	
	if (v >= vMin)
	{
		s := v
		w := wMax
	}
	else
	{
		s := vMin
		w := wMax - vMin + v
	}
	
	SoundSet, %s%
	SoundSet, %w%, WAVE
	OSD(v) ; display volume on screen
}

*/

;; On-screen display ----------------------------------------------------------

;; -> init

Gui, OSD:+AlwaysOnTop +LastFound +Owner +Disabled -Caption
Gui, OSD:Color, FFFFFF
Gui, OSD:Font, s30, VCR OSD Mono
Gui, OSD:Add, Text, vOSD c00BB00, % "        "
WinSet, TransColor, FFFFFF 250
y := A_ScreenHeight - 100
Gui, OSD:Show, x0 y%y% AutoSize NA, OSD

;; -> library

OSD(text)
{
	SetTimer, RemoveOSD, Off
	WinSet, AlwaysOnTop, On, OSD
	GuiControl, OSD:Text, OSD, %text%
	SetTimer, RemoveOSD, 3000
	return
}

RemoveOSD:
SetTimer, RemoveOSD, Off
GuiControl, OSD:Text, OSD, % " "
return