PageRenderTime 77ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/docs/scripts/VolumeOSD.ahk

http://github.com/Lexikos/AutoHotkey_L-Docs
AutoHotKey | 127 lines | 71 code | 24 blank | 32 comment | 3 complexity | 0ca65ab11f84897d4219724138fe7271 MD5 | raw file
  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. ;_______User Settings_____________________________
  8. ; Make customisation only in this area or hotkey area only!!
  9. ; The percentage by which to raise or lower the volume each time:
  10. vol_Step = 4
  11. ; How long to display the volume level bar graphs:
  12. vol_DisplayTime = 2000
  13. ; Master Volume Bar color (see the help file to use more
  14. ; precise shades):
  15. vol_CBM = Red
  16. ; Wave Volume Bar color
  17. vol_CBW = Blue
  18. ; Background color
  19. vol_CW = Silver
  20. ; Bar's screen position. Use -1 to center the bar in that dimension:
  21. vol_PosX = -1
  22. vol_PosY = -1
  23. vol_Width = 150 ; width of bar
  24. vol_Thick = 12 ; thickness of bar
  25. ; If your keyboard has multimedia buttons for Volume, you can
  26. ; try changing the below hotkeys to use them by specifying
  27. ; Volume_Up, ^Volume_Up, Volume_Down, and ^Volume_Down:
  28. HotKey, #Up, vol_MasterUp ; Win+UpArrow
  29. HotKey, #Down, vol_MasterDown
  30. HotKey, +#Up, vol_WaveUp ; Shift+Win+UpArrow
  31. HotKey, +#Down, vol_WaveDown
  32. ;___________________________________________
  33. ;_____Auto Execute Section__________________
  34. ; DON'T CHANGE ANYTHING HERE (unless you know what you're doing).
  35. vol_BarOptionsMaster = 1:B ZH%vol_Thick% ZX0 ZY0 W%vol_Width% CB%vol_CBM% CW%vol_CW%
  36. vol_BarOptionsWave = 2:B ZH%vol_Thick% ZX0 ZY0 W%vol_Width% CB%vol_CBW% CW%vol_CW%
  37. ; If the X position has been specified, add it to the options.
  38. ; Otherwise, omit it to center the bar horizontally:
  39. if vol_PosX >= 0
  40. {
  41. vol_BarOptionsMaster = %vol_BarOptionsMaster% X%vol_PosX%
  42. vol_BarOptionsWave = %vol_BarOptionsWave% X%vol_PosX%
  43. }
  44. ; If the Y position has been specified, add it to the options.
  45. ; Otherwise, omit it to have it calculated later:
  46. if vol_PosY >= 0
  47. {
  48. vol_BarOptionsMaster = %vol_BarOptionsMaster% Y%vol_PosY%
  49. vol_PosY_wave = %vol_PosY%
  50. vol_PosY_wave += %vol_Thick%
  51. vol_BarOptionsWave = %vol_BarOptionsWave% Y%vol_PosY_wave%
  52. }
  53. #SingleInstance
  54. SetBatchLines, 10ms
  55. Return
  56. ;___________________________________________
  57. vol_WaveUp:
  58. SoundSet, +%vol_Step%, Wave
  59. Gosub, vol_ShowBars
  60. return
  61. vol_WaveDown:
  62. SoundSet, -%vol_Step%, Wave
  63. Gosub, vol_ShowBars
  64. return
  65. vol_MasterUp:
  66. SoundSet, +%vol_Step%
  67. Gosub, vol_ShowBars
  68. return
  69. vol_MasterDown:
  70. SoundSet, -%vol_Step%
  71. Gosub, vol_ShowBars
  72. return
  73. vol_ShowBars:
  74. ; To prevent the "flashing" effect, only create the bar window if it
  75. ; doesn't already exist:
  76. IfWinNotExist, vol_Wave
  77. Progress, %vol_BarOptionsWave%, , , vol_Wave
  78. IfWinNotExist, vol_Master
  79. {
  80. ; Calculate position here in case screen resolution changes while
  81. ; the script is running:
  82. if vol_PosY < 0
  83. {
  84. ; Create the Wave bar just above the Master bar:
  85. WinGetPos, , vol_Wave_Posy, , , vol_Wave
  86. vol_Wave_Posy -= %vol_Thick%
  87. Progress, %vol_BarOptionsMaster% Y%vol_Wave_Posy%, , , vol_Master
  88. }
  89. else
  90. Progress, %vol_BarOptionsMaster%, , , vol_Master
  91. }
  92. ; Get both volumes in case the user or an external program changed them:
  93. SoundGet, vol_Master, Master
  94. SoundGet, vol_Wave, Wave
  95. Progress, 1:%vol_Master%
  96. Progress, 2:%vol_Wave%
  97. SetTimer, vol_BarOff, %vol_DisplayTime%
  98. return
  99. vol_BarOff:
  100. SetTimer, vol_BarOff, off
  101. Progress, 1:Off
  102. Progress, 2:Off
  103. return