AutoHotkey Community

It is currently May 27th, 2012, 4:09 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: September 24th, 2009, 12:19 pm 
Offline

Joined: September 24th, 2009, 10:46 am
Posts: 1
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 :wink:.

Feel free to customize it in any way you want. Tested on Windows 7 x64 build 7100.

Image

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 January 23rd, 2010, 11:22 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 27th, 2009, 9:21 pm 
Offline

Joined: September 28th, 2007, 7:23 pm
Posts: 37
Your script works great. Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2010, 7:40 pm 
Offline

Joined: July 1st, 2008, 1:28 pm
Posts: 13
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2011, 9:03 pm 
Offline

Joined: June 11th, 2005, 9:34 am
Posts: 264
Location: England ish
I adore your work!

I've been looking for something simple that just works. Perfect!

Thanks

_________________
::
I Have Spoken
::


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 23rd, 2011, 12:08 pm 
Offline

Joined: June 16th, 2011, 3:00 pm
Posts: 9
Location: Sweden
Awesome script. Could you implement a mute hotkey too?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 23rd, 2011, 12:37 pm 
Offline
User avatar

Joined: May 18th, 2010, 3:10 pm
Posts: 1179
Location: Sweden
Void wrote:
Awesome script. Could you implement a mute hotkey too?


Edit the script to include this line below a hotkey of your choice:

Code:
VA_SetMute(True)

_________________
~sumon Appifyer AHK Nova halted Recommended: AHK_L (Why?)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 23rd, 2011, 1:06 pm 
Offline

Joined: June 16th, 2011, 3:00 pm
Posts: 9
Location: Sweden
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:

Code:
VA_SetMute(True)


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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 23rd, 2011, 4:15 pm 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
Code:
VA_SetMute(toggle := !toggle)

_________________
Autofire, AutoClick, Toggle, SpamWindow Control Tools
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 23rd, 2011, 4:17 pm 
Offline

Joined: June 16th, 2011, 3:00 pm
Posts: 9
Location: Sweden
nimda wrote:
Code:
VA_SetMute(toggle := !toggle)


nice ty :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 27th, 2011, 9:53 am 
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 :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 18th, 2011, 6:03 am 
Very useful, must say. The OSD volume display is a nice touch, especially.


Report this post
Top
  
Reply with quote  
PostPosted: August 3rd, 2011, 2:23 pm 
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


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Stigg and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group