]> Tony Duckles's Git Repositories (git.nynim.org) - autohotkey-scripts.git/blob - VolumeOSD.ahk
Init AutoHotKey
[autohotkey-scripts.git] / VolumeOSD.ahk
1 ; Volume On-Screen-Display (OSD) -- by Rajat
2 ; http://www.autohotkey.com
3 ; This script assigns hotkeys of your choice to raise and lower the
4 ; master and/or wave volume. Both volumes are displayed as different
5 ; color bar graphs.
6
7 ;_________________________________________________
8 ;_______User Settings_____________________________
9
10 ; Make customisation only in this area or hotkey area only!!
11
12 ; The percentage by which to raise or lower the volume each time:
13 vol_Step = 4
14
15 ; How long to display the volume level bar graphs:
16 vol_DisplayTime = 2000
17
18 ; Master Volume Bar color (see the help file to use more
19 ; precise shades):
20 vol_CBM = Lime
21
22 ; Background color; for transparent, set to 111111
23 vol_CW = 111111
24
25 ; Bar's screen position. Use -1 to center the bar in that dimension:
26 vol_PosX = -1
27 vol_PosY = 600
28 vol_Width = 400 ; width of bar
29 vol_Thick = 20 ; thickness of bar
30
31 ; If your keyboard has multimedia buttons for Volume, you can
32 ; try changing the below hotkeys to use them by specifying
33 ; Volume_Up, ^Volume_Up, Volume_Down, and ^Volume_Down:
34 ;HotKey, Volume_Up, vol_MasterUp
35 ;HotKey, Volume_Down, vol_MasterDown
36
37 HotKey, #Up, vol_MasterUp ; Win+UpArrow
38 HotKey, #Down, vol_MasterDown
39 HotKey, ^!Up, vol_MasterUp ; Ctrl+Alt+UpArrow
40 HotKey, ^!Down, vol_MasterDown
41
42
43 ;___________________________________________
44 ;_____Auto Execute Section__________________
45
46 ; DON'T CHANGE ANYTHING HERE (unless you know what you're doing).
47
48 COM_Init()
49
50 vol_BarOptionsMaster = 1 ZH%vol_Thick% ZX0 ZY0 W%vol_Width% CB%vol_CBM% CW%vol_CW%
51 ;vol_BarOptionsMaster = 1 ZH%vol_Thick% ZX0 ZY0 W%vol_Width%
52
53 ; If the X position has been specified, add it to the options.
54 ; Otherwise, omit it to center the bar horizontally:
55 if vol_PosX >= 0
56 {
57 vol_BarOptionsMaster = %vol_BarOptionsMaster% X%vol_PosX%
58 }
59
60 ; If the Y position has been specified, add it to the options.
61 ; Otherwise, omit it to have it calculated later:
62 if vol_PosY >= 0
63 {
64 vol_BarOptionsMaster = %vol_BarOptionsMaster% Y%vol_PosY%
65 }
66
67 #SingleInstance
68 SetBatchLines, 10ms
69 Return
70
71
72 ;___________________________________________
73
74 vol_MasterUp:
75 vol_tmp := VA_GetMasterVolume()
76 vol_Master := (vol_tmp + vol_Step)
77 VA_SetMasterVolume(vol_Master)
78 Gosub, vol_ShowBars
79 return
80
81 vol_MasterDown:
82 vol_tmp := VA_GetMasterVolume()
83 vol_Master := (vol_tmp - vol_Step)
84 VA_SetMasterVolume(vol_Master)
85 Gosub, vol_ShowBars
86 return
87
88 vol_ShowBars:
89 ; To prevent the "flashing" effect, only create the bar window if it
90 ; doesn't already exist:
91 IfWinNotExist, vol_Progress
92 {
93 ; Calculate position here in case screen resolution changes while
94 ; the script is running:
95 Progress, %vol_BarOptionsMaster%, , , vol_Progress
96 ;WinSet, TransColor, 111111, vol_Progress
97 }
98 ; Get the volume in case the user or an external program changed them:
99 vol_Master := VA_GetMasterVolume()
100 Progress, 1:%vol_Master%
101 SetTimer, vol_BarOff, %vol_DisplayTime%
102 return
103
104 vol_BarOff:
105 SetTimer, vol_BarOff, off
106 Progress, 1:Off
107 return