##title##

2010年8月14日

AutoHotkey:OSD顯示調整音量設定

※Windows XP適用。

Volume On-Screen-Display (OSD) -- by Rajat
可以調整音量,並用OSD的顯示方式來讓使用者知道目前音量的大小,對於沒有調整音量的喇叭,或者是直接把耳機插在音效輸出孔上的使用者來說,可以說是相當方便的功能。

原始 Script 可以參考:http://www.autohotkey.com/docs/scripts/VolumeOSD.htm

不過原始 Script 如果直接放進自己常用的 Script 裡頭,可能會造成原本的 Script 失效,而且不把 Script 放在最前面也可能會失效。(因為可能會和原本自己寫的 Script 衝突)

為了解決這個問題,我把 Script 稍微改了一下。(順便也把熱鍵修改成用滾輪)

只要在自己的 Script 中加入這一行:
 
#include %A_ScriptDir%\volumeosd.ahk


然後把下面這段 Script 另存為 volumeosd.ahk,並存放到自己常用的 Script 資料夾下就可以使用了囉。

 
; If your keyboard has multimedia buttons for Volume, you can
; try changing the below hotkeys to use them by specifying
; Volume_Up, ^Volume_Up, Volume_Down, and ^Volume_Down:
#WheelUp::
Gosub, volumeosdini
Gosub, vol_MasterUp ;Win+WheelUp
return
#WheelDown::
Gosub, volumeosdini
Gosub, vol_MasterDown ;Win+WheelDown
return
#+WheelUp::
Gosub, volumeosdini
Gosub, vol_WaveUp ;Win+Shift+WheelUp
return
#+WheelDown::
Gosub, volumeosdini
Gosub, vol_WaveDown ;Win+Shift+WheelDown
return

volumeosdini:
;_________________________________________________
;_______User Settings_____________________________
; Make customisation only in this area or hotkey area only!!
; The percentage by which to raise or lower the volume each time:
vol_Step = 3
; How long to display the volume level bar graphs:
vol_DisplayTime = 1000
; Master Volume Bar color (see the help file to use more
; precise shades):
vol_CBM = Red
; Wave Volume Bar color
vol_CBW = Blue
; Background color
vol_CW = Silver
; Bar's screen position. Use -1 to center the bar in that dimension:
vol_PosX = -1
vol_PosY = -1
vol_Width = 150 ; width of bar
vol_Thick = 12 ; thickness of bar
;___________________________________________
;_____Auto Execute Section__________________
; DON'T CHANGE ANYTHING HERE (unless you know what you're doing).
vol_BarOptionsMaster = 1:B ZH%vol_Thick% ZX0 ZY0 W%vol_Width% CB%vol_CBM% CW%vol_CW%
vol_BarOptionsWave = 2:B ZH%vol_Thick% ZX0 ZY0 W%vol_Width% CB%vol_CBW% CW%vol_CW%
; If the X position has been specified, add it to the options.
; Otherwise, omit it to center the bar horizontally:
if vol_PosX >= 0
{
vol_BarOptionsMaster = %vol_BarOptionsMaster% X%vol_PosX%
vol_BarOptionsWave = %vol_BarOptionsWave% X%vol_PosX%
}
; If the Y position has been specified, add it to the options.
; Otherwise, omit it to have it calculated later:
if vol_PosY >= 0
{
vol_BarOptionsMaster = %vol_BarOptionsMaster% Y%vol_PosY%
vol_PosY_wave = %vol_PosY%
vol_PosY_wave += %vol_Thick%
vol_BarOptionsWave = %vol_BarOptionsWave% Y%vol_PosY_wave%
}
#SingleInstance
SetBatchLines, 10ms
Return
;___________________________________________
vol_WaveUp:
SoundSet, +%vol_Step%, Wave
Gosub, vol_ShowBars
return

vol_WaveDown:
SoundSet, -%vol_Step%, Wave
Gosub, vol_ShowBars
return

vol_MasterUp:
SoundSet, +%vol_Step%
Gosub, vol_ShowBars
return

vol_MasterDown:
SoundSet, -%vol_Step%
Gosub, vol_ShowBars
return

vol_ShowBars:
; To prevent the "flashing" effect, only create the bar window if it
; doesn't already exist:
IfWinNotExist, vol_Wave
Progress, %vol_BarOptionsWave%, , , vol_Wave
IfWinNotExist, vol_Master
{
; Calculate position here in case screen resolution changes while
; the script is running:
if vol_PosY < 0
{
; Create the Wave bar just above the Master bar:
WinGetPos, , vol_Wave_Posy, , , vol_Wave
vol_Wave_Posy -= %vol_Thick%
Progress, %vol_BarOptionsMaster% Y%vol_Wave_Posy%, , , vol_Master
}
else
Progress, %vol_BarOptionsMaster%, , , vol_Master
}
; Get both volumes in case the user or an external program changed them:
SoundGet, vol_Master, Master
SoundGet, vol_Wave, Wave
Progress, 1:%vol_Master%
Progress, 2:%vol_Wave%
SetTimer, vol_BarOff, %vol_DisplayTime%
return

vol_BarOff:
SetTimer, vol_BarOff, off
Progress, 1:Off
Progress, 2:Off
return


以上是改自 Rajat 大大的 Script,不過我個人是習慣再加上靜音的功能,所以你也可以把這一段加在 Script 裡頭。

 
#MButton:: ;windows+滑鼠中鍵,切換聲音/靜音
Send {Volume_Mute}
return


或者把顏色改成這樣,我個人還蠻喜歡這樣的搭配:
 
; Master Volume Bar color (see the help file to use more
; precise shades):
vol_CBM = A7FF35 ;黃綠色
; Wave Volume Bar color
vol_CBW = 44CAFF ;淺藍色
; Background color
vol_CW = 4C4C4C ;深藍色

沒有留言:

張貼留言