Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Just another Volume OSD


  • Please log in to reply
37 replies to this topic
Sjc1000
  • Members
  • 572 posts
  • Last active: Mar 11 2017 11:41 AM
  • Joined: 06 Feb 2012

Hello again,

 

 

Im sure everyone has seen one of these, and with the new SoundGet / SoundSet support with Win 7 i think there will be a few Volume OSD's. So, i thought i may as well chuck in my own model. 

 

Mine is pretty much fully customize-able, you can change all the colours, the area it shows up in, the transparency, hotkeys for vol up and down and the timeout it stays on your screen for.

 

This uses an update system that will check for the volume, so it will show the OSD whenever the volume gets changed, even if its from outside of the ahk script. No matter what changes the volume this will show it happy.png

 

Say no more, see no less here is my 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

Enjoy.


Sjc1000 - Insert inspirational quote here!

PLEASE find me on the IRC if you have questions. I'm never on the forum anymore.

 


TBolt
  • Members
  • 2 posts
  • Last active: Sep 17 2013 06:52 AM
  • Joined: 15 Jul 2013

Hi. Does this have support for volume mute? If so, which keys mute the volume?

 

Thank you.



Sjc1000
  • Members
  • 572 posts
  • Last active: Mar 11 2017 11:41 AM
  • Joined: 06 Feb 2012

Hi TBolt, Welcome to the AutoHotkey forum and community.

 

I have added this into the script.

 

Spoiler

Sjc1000 - Insert inspirational quote here!

PLEASE find me on the IRC if you have questions. I'm never on the forum anymore.

 


TBolt
  • Members
  • 2 posts
  • Last active: Sep 17 2013 06:52 AM
  • Joined: 15 Jul 2013

Hi TBolt, Welcome to the AutoHotkey forum and community.

 

I have added this into the script.

 

Spoiler

 

Thank you so much, Sjc!  I can't wait to try it out later.

 

I appreciate the update to the script!  :)



joedf
  • Administrators
  • 986 posts
  • AutoHotkey Foundation
  • Last active: Nov 02 2019 08:38 PM
  • Joined: 20 May 2012

pretty cool!


Why ahkscript.org? - autohotkey.com is outdated

ozzii
  • Members
  • 167 posts
  • Last active: Oct 30 2015 04:54 PM
  • Joined: 23 Mar 2011

@Sjc1000

Can you make a little changes for me. I've tried but with no luck.

 

Can you add that the volume also work when I mouse over the tray and use the whellmouse.

Like here http://www.autohotke...ple-volume-osd/)?

 

Thanks in advance.



Sjc1000
  • Members
  • 572 posts
  • Last active: Mar 11 2017 11:41 AM
  • Joined: 06 Feb 2012

Hi ozzii, i have added these changes.

 

I decided to make it optional. ( changeable by variable ).

 

Spoiler

Sjc1000 - Insert inspirational quote here!

PLEASE find me on the IRC if you have questions. I'm never on the forum anymore.

 


joedf
  • Administrators
  • 986 posts
  • AutoHotkey Foundation
  • Last active: Nov 02 2019 08:38 PM
  • Joined: 20 May 2012
Haha lol, Nice vie tried it, i tested by running both scripts at the same Time. Worked well, all that is needed is the mouse over tray code (optional defined by var) from my script ;)

I really like the winset region idea! Nice :)
Why ahkscript.org? - autohotkey.com is outdated

ozzii
  • Members
  • 167 posts
  • Last active: Oct 30 2015 04:54 PM
  • Joined: 23 Mar 2011

Thanks for the quick update.

If I may some things....

-Now the hotkeys works only when the mouse is over the tray. Not just the wheel but also the VolUp_Key VolDown_Key. I thinking that the tray is just for the wheel not also for the regular keys.

-I put the volume to 0. I do one VolUp_Key, I have the sound but in the gui it's 0%. Same with the VolDown from 1% to 0%.

-When i put 5 for amount, the first shown is 4% and not 5. But after that the gui is updated from 5 to 5. (think this is related to the previous point)

-I also have a window Vol_OSD in the work bar beside the start button. how can I do to deactivate this?

 

Thanks again. really love your gui...



ozzii
  • Members
  • 167 posts
  • Last active: Oct 30 2015 04:54 PM
  • Joined: 23 Mar 2011

Double post.....



Sjc1000
  • Members
  • 572 posts
  • Last active: Mar 11 2017 11:41 AM
  • Joined: 06 Feb 2012

Thanks for all the feedback. Also thanks for these bug reports. I have fixed up everything.

 

Spoiler

 

 

EDIT: Changed around the code a little bit.

EDIT: Updated so you don't need to specify x in Gui_X and y in Gui_Y. You can just put the number straight in.


Sjc1000 - Insert inspirational quote here!

PLEASE find me on the IRC if you have questions. I'm never on the forum anymore.

 


klownboy
  • Members
  • 87 posts
  • Last active: May 24 2014 11:21 AM
  • Joined: 20 Jul 2012

Hi Sjc1000, It's been awhile.  I hope all is well.  Very nice script.  I just ran it though and it comes up most of the time partially hidden by my task bar.  I'm running Windows 7 with Task Bar Properties set to "Lock task bar" and "Auto Hide taskbar".  It seems inconsistent on when it does it, if I have a program active (actually even when I have all programs minimized too) and mouse down to the task bar and the taskbar raises, the volume OSD usually comes up partially hidden by the taskbar.  So I raised it to a setting for "y" of "A_ScreenHeight - 139" to have it surface just on top of the raised taskbar.  Thanks again.

Ken



ozzii
  • Members
  • 167 posts
  • Last active: Oct 30 2015 04:54 PM
  • Joined: 23 Mar 2011

Thanks Sjc1000 for the update...

 

2 things:

1- I prefer the gui in the middle of the screen (like the previous version)... Maybe an option for that (now I've done a A_ScreenHeight / 2 - 50)?

2- What do you think that when we do a mute a gui with a red bar is showed. And when we unmute, the normal gui is shown ? Or a new gui with just written in red mute and in green unmute.

 

Thanks again for your work.



Sjc1000
  • Members
  • 572 posts
  • Last active: Mar 11 2017 11:41 AM
  • Joined: 06 Feb 2012

Hey klownboy, it has been a while. A far while actually.

 

Thanks again for all the feedback.

 

Both of your responses seem to be about the positioning. This is already fully changeable. ozzii, please take notice of the Gui_Y and Gui_X variables, change these to suit you. Also take notice of the Gui_W variable, this has been changed since the last versions.

 

As for your request on the mute / un-mute thing. I was thinking ill just make the text red and bold when you have it muted, and your selected color when its not. I will work on these as soon as i get some time. 


Sjc1000 - Insert inspirational quote here!

PLEASE find me on the IRC if you have questions. I'm never on the forum anymore.

 


Sjc1000
  • Members
  • 572 posts
  • Last active: Mar 11 2017 11:41 AM
  • Joined: 06 Feb 2012

And here is that update. ozzii, please pay attention to the Gui_X and Gui_Y variables.

 

Spoiler

Sjc1000 - Insert inspirational quote here!

PLEASE find me on the IRC if you have questions. I'm never on the forum anymore.