QaniTri- Admin
-
Tổng số bài gửi : 1609
Tiền xu Ⓑ : 3986
Được cảm ơn № : 6
Ngày khởi sự : 07/01/2013
Đến từ : HCMC
Côngviệc / Sởthix : Languages, Softwares, Sciences, Martial arts
by QaniTri 18th July 2016, 01:22
- Code:
/*
Based on the example from: http://l.autohotkey.net/docs/commands/_If.htm
parts "forked" from Update.ahk
----------------------------------------
This version, joedf, April 8th, 2013
- Update May 23rd, 2013 [r1] - Added Tooltip to display volume %
- Update June 4th, 2013 [r2] - Added Volume OSD
- Update June 6th, 2013 [r3] - Added Hotkeys & over_tray options, Suggested by DataLife
*/
;_______[Settings]_______
Volume_Delay:=1000
BG_color=1A1A1A
Text_color=FFFFFF
Bar_color=666666
Volume_OSD_Center:=1
over_tray:=0
;________________________
;________[HOTKEYS]_______
vol_up = WheelUp
vol_down = WheelDown
vol_up_fast = +%vol_up% ;shift + (vol_up) hotkey
vol_down_fast = +%vol_down% ;shift + (vol_down) hotkey
;________________________
;//////////////[Do not edit after this line]///////////////
#If % (over_tray) ? MouseIsOver("ahk_class Shell_TrayWnd") : "(1)"
Hotkey, If, % (over_tray) ? MouseIsOver("ahk_class Shell_TrayWnd") : "(1)"
Hotkey,%vol_up%,vol_up
Hotkey,%vol_down%,vol_down
Hotkey,%vol_up_fast%,vol_up_fast
Hotkey,%vol_down_fast%,vol_down_fast
return
vol_up:
Send {Volume_Up}
gosub, Volume_Show_OSD
return
vol_up_fast:
Send {Volume_Up 4}
gosub, Volume_Show_OSD
return
vol_down:
Send {Volume_Down}
gosub, Volume_Show_OSD
return
vol_down_fast:
Send {Volume_Down 4}
gosub, Volume_Show_OSD
return
Volume_Show_OSD:
if (Volume_OSD_Center)
{
mY := (A_ScreenHeight/2)-26, mX := (A_ScreenWidth/2)-165
}
else
{
SysGet m, MonitorWorkArea, 1
mY := mBottom-52-2, mX := mRight-330-2
}
SoundGet, Volume
if (!Volume_OSD_c)
{
Volume_ProgressbarOpts=CW%BG_color% CT%Text_color% CB%Bar_color% x%mX% y%mY% w330 h52 B1 FS8 WM700 WS700 FM8 ZH12 ZY3 C11
Progress Hide %Volume_ProgressbarOpts%,,Volume,, Tahoma
Volume_OSD_c:=!Volume_OSD_c
}
Progress Show
Progress % Volume := Round(Volume), %Volume% `%
SetTimer, Remove_Show_OSD, %Volume_Delay%
return
Remove_Show_OSD:
SetTimer, Remove_Show_OSD, Off
Progress Hide %Volume_ProgressbarOpts%,,Volume,,Tahoma
return
MouseIsOver(WinTitle) {
MouseGetPos,,, Win
return WinExist(WinTitle . " ahk_id " . Win)
}
- Code:
;_________________________________________________
;_______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 = 4
; How long to display the volume level bar graphs:
vol_DisplayTime = 2000
; 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
; 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:
HotKey, #Up, vol_MasterUp ; Win+UpArrow
HotKey, #Down, vol_MasterDown
HotKey, +#Up, vol_WaveUp ; Shift+Win+UpArrow
HotKey, +#Down, vol_WaveDown
;___________________________________________
;_____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
- Code:
#NoEnv
#SingleInstance, force
; We want exact title match
SetTitleMatchMode 3
; Create hotkey volume control linking
Volume_Down::VolumeDown()
Volume_Up::VolumeUp()
VolumeUp()
{
SoundSet, +2.5, MASTER, VOLUME
ShowVolumeControl()
}
VolumeDown()
{
SoundSet, -2.5, MASTER, VOLUME
ShowVolumeControl()
}
ShowVolumeControl()
{
; Calculate progress bar position lower right screen
DialogWidth := 300
SysGet, MonitorArea, MonitorWorkArea, 1
Left := (MonitorAreaRight - DialogWidth) - 50
Top := (MonitorAreaBottom - 100)
; You may uncomment lower 3 lines to place volume bar in lower left corner of second monitor
;SysGet, MonitorArea, MonitorWorkArea, 2
;Left := (MonitorAreaLeft + 50)
;Top := (MonitorAreaBottom - 100)
; Get current Volume and display in progress bar
SoundGet, VolumePercent, MASTER, VOLUME
; If progress window is already shown, we only update progress to avoid flicker
IfWinExist, Volume
{
Progress, %VolumePercent%
}
else
{
Progress, B2 X%Left% Y%Top% W%DialogWidth% P%VolumePercent%, , Volume, Volume
}
; Setup timer to hide progress bar after 1 second
SetTimer, HideVolumeBar, -1000
Return
; Hide progress bar
HideVolumeBar:
Progress, Off
Return
}
- Code:
;---------- Volume OSD
;------ User Variables ( Feel free to change these )
Gui_X := ""
Gui_Y := "y50"
Back_Colour := 0x000000
Font_Colour := 0xFFFFFF
BackBar_Colour := 0x000000
Bar_Colour := 0x0000FF
VolUp_Key := "^!="
VolDown_Key := "^!-"
Ammount := 1
Timeout := 2500
Max_Trans := 200
;------- End of user variables
Update := 0
SoundGet, Vol
Curr_Vol := Vol
Trans := Max_Trans
Gui, Color, % Back_Colour,
Gui, Font, c%Font_Colour% s12
Gui, Add, Text, w500 Center, Volume
Gui, Font
Gui, Add, Progress, w500 vProgress c%Bar_Colour% +Background%BackBar_Colour%, % Curr_Vol
Gui, Font, c%Font_Colour% s24
SoundGet, Vol
RegExMatch( Vol, "(?<Percent>\d+)\.", rg )
Gui, Add, Text, w500 Center vVol, % rgPercent
Gui, Show, NoActivate h80 w530 %Gui_X% %Gui_Y%, Vol_OSD
WinSet, Region, w530 h105 R10-10 0-0, Vol_OSD
WinSet, Transparent, %Trans%, Vol_OSD
Gui, -Caption +AlwaysOnTop +ToolWindow +E0x20 +SysMenu
Hotkey, % VolUp_Key, Volume_Up
Hotkey, % VolDown_Key, Volume_Down
SetTimer, Update, 50
SetTimer, Fade, % "-" Timeout
return
Fade:
While ( Trans > 0 && Update = 0)
{ Trans -= 2
WinSet, Transparent, % Trans, Vol_OSD
Sleep, 5
}
Return
Update:
Update := 0
SoundGet, Vol
If ( Vol <> Curr_Vol )
{ Update := 1
GuiControl,, Progress, % Vol
RegExMatch( Vol, "(?<Percent>\d+)\.", rg )
GuiControl,, Vol, % rgPercent
Curr_Vol := Vol
While ( Trans < Max_Trans )
{ Trans += 10
WinSet, Transparent, % Trans, Vol_OSD
Sleep 1
}
SetTimer, Fade, % "-" Timeout
}
Return
Volume_Down:
SoundSet, -%Ammount%, MASTER
return
Volume_Up:
SoundSet, +%Ammount%, MASTER
Return