| View previous topic :: View next topic |
| Author |
Message |
mrfantastic
Joined: 24 Sep 2009 Posts: 1
|
Posted: Thu Sep 24, 2009 11:19 am Post subject: Vista / Windows 7 Simple Volume Control |
|
|
Based on paftdunk's Volume OSD.
Requires COM and VA libraries to work properly. Simply download appropriate .ahk files and put them into your ...\AutoHotkey\Lib\ folder.
Simple Volume Control increases or decreases master volume using following hotkeys:
- Media Volume Up / Media Volume Down
- Win+UpArrow / Win+DownArrow
- MouseButton5+MouseScrollUp / MouseButton5+MouseScrollDown
When you set master volume to 0 it actually mutes all sounds, because Windows 7, for some strange reason, keeps playing music even if you set master volume to 0.
That's it. This script doesn't do anything else .
Feel free to customize it in any way you want. Tested on Windows 7 x64 build 7100.
| Code: |
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance force
SetBatchLines -1
COM_Init()
vol_Master := VA_GetMasterVolume()
; -------------------
; START CONFIGURATION
; -------------------
; The percentage by which to raise or lower the volume each time
vol_Step = 3
; How long to display the volume level bar graphs (in milliseconds)
vol_DisplayTime = 1000
; Transparency of window (0-255)
vol_TransValue = 255
; Bar's background colour
vol_CW = EEEEEE
vol_Width = 200 ; width of bar
vol_Thick = 20 ; thickness of bar
; Bar's screen position
vol_PosX := A_ScreenWidth - vol_Width - 50
vol_PosY := A_ScreenHeight - vol_Thick - 100
; --------------------
; END OF CONFIGURATION
; --------------------
vol_BarOptionsMaster = 1:B1 ZH%vol_Thick% ZX8 ZY4 W%vol_Width% X%vol_PosX% Y%vol_PosY% CW%vol_CW%
return
$Volume_down::
#Down::
~XButton2 & WheelDown::
{
if vol_Master > .01
{
VA_SetMasterVolume(vol_Master-=vol_Step)
if vol_Master <= 0
{
VA_SetMute(True)
}
}
Gosub, vol_ShowBars
}
return
$Volume_up::
#Up::
~XButton2 & WheelUp::
{
if vol_Master <= 99
{
VA_SetMasterVolume(vol_Master+=vol_Step)
if vol_Master > 1
{
VA_SetMute(False)
}
}
Gosub, vol_ShowBars
}
return
vol_ShowBars:
; Get volumes in case the user or an external program changed them:
vol_Master := VA_GetMasterVolume()
vol_Mute := VA_GetMasterMute()
if vol_Mute <> 1
{
vol_Colour = Green
vol_Text = Volume
}
else
{
vol_Colour = Red
vol_Text = Volume (muted)
}
; To prevent the "flashing" effect, only create the bar window if it doesn't already exist:
IfWinNotExist, VolumeOSDxyz
{
Progress, %vol_BarOptionsMaster% CB%vol_Colour% CT%vol_Colour%, , %vol_Text%, VolumeOSDxyz
WinSet, Transparent, %vol_TransValue%, VolumeOSDxyz
}
Progress, 1:%vol_Master%, , %vol_Text%
SetTimer, vol_BarOff, %vol_DisplayTime%
return
vol_BarOff:
SetTimer, vol_BarOff, off
Progress, 1:Off
return
|
Last edited by mrfantastic on Sat Jan 23, 2010 10:22 am; edited 1 time in total |
|
| Back to top |
|
 |
n00ge
Joined: 28 Sep 2007 Posts: 37
|
Posted: Sun Sep 27, 2009 8:21 pm Post subject: |
|
|
| Your script works great. Thanks. |
|
| Back to top |
|
 |
zavjah
Joined: 01 Jul 2008 Posts: 13
|
Posted: Thu May 06, 2010 6:40 pm Post subject: |
|
|
Hi mrfantastic,
Cool job. Thanks for the code.
Is there a way to force a change of the script icon when master volume is muted, to signaliez it all the time. As soon the volume differ from 0, then the icon should chang back. _________________ Thanks,
zuvjah
______________________________________________________________________
Still a beginner but I love the AHK |
|
| Back to top |
|
 |
TheLeO
Joined: 11 Jun 2005 Posts: 264 Location: England ish
|
Posted: Sun Jan 30, 2011 8:03 pm Post subject: |
|
|
I adore your work!
I've been looking for something simple that just works. Perfect!
Thanks _________________ ::
I Have Spoken
:: |
|
| Back to top |
|
 |
Void
Joined: 16 Jun 2011 Posts: 9 Location: Sweden
|
Posted: Thu Jun 23, 2011 11:08 am Post subject: |
|
|
| Awesome script. Could you implement a mute hotkey too? |
|
| Back to top |
|
 |
sumon
Joined: 18 May 2010 Posts: 1016 Location: Sweden
|
Posted: Thu Jun 23, 2011 11:37 am Post subject: |
|
|
| Void wrote: | | Awesome script. Could you implement a mute hotkey too? |
Edit the script to include this line below a hotkey of your choice:
|
|
| Back to top |
|
 |
Void
Joined: 16 Jun 2011 Posts: 9 Location: Sweden
|
Posted: Thu Jun 23, 2011 12:06 pm Post subject: |
|
|
| sumon wrote: | | Void wrote: | | Awesome script. Could you implement a mute hotkey too? |
Edit the script to include this line below a hotkey of your choice:
|
Thank u Modified it to work as a toggle key adding:
| Code: | Insert::
toggle:=!toggle
if toggle
VA_SetMute(True)
Else
VA_SetMute(False)
return |
|
|
| Back to top |
|
 |
nimda
Joined: 26 Dec 2010 Posts: 3856 Location: Awesometown, USA
|
|
| Back to top |
|
 |
Void
Joined: 16 Jun 2011 Posts: 9 Location: Sweden
|
Posted: Thu Jun 23, 2011 3:17 pm Post subject: |
|
|
| nimda wrote: | | Code: | | VA_SetMute(toggle := !toggle) |
|
nice ty  |
|
| Back to top |
|
 |
pantheon Guest
|
Posted: Mon Jun 27, 2011 8:53 am Post subject: |
|
|
Hello,
Thank you for your script !
My problem is :
I have 2 cards sounds :
- C-Media PCI Audio Device (default)
- Realtek High Definition Audio
I would like to modify volume of my second card sound (Realtek High Definition Audio). Is it possible ?
PS : I must keep C-Media in default card sound.
Thank you for your help  |
|
| Back to top |
|
 |
Shurane Guest
|
Posted: Mon Jul 18, 2011 5:03 am Post subject: |
|
|
| Very useful, must say. The OSD volume display is a nice touch, especially. |
|
| Back to top |
|
 |
JerryR Guest
|
Posted: Wed Aug 03, 2011 1:23 pm Post subject: can't get volume hotkeys to work |
|
|
Hi, Can you tell me which autohotkey program and which COM file I should use? I have Windows 7, 64 bit. I've tried two or three of the volume hotkey scripts and can't get any to work. If they work at all, they just turn the volume all the way down, no matter whcih keystroke I press. So, I thought at least I would make sure I have the right stuff first.
Thank you. Jerry |
|
| Back to top |
|
 |
|