Sign in to follow this  
Followers 0
mihaibr

Custom Volume Buttons and Custom Volume tray icons

1 post in this topic

#1 ·  Posted (edited)

Hi,

Today I bought a new keyboard and at home I noticed that it doesn't have buttons for the volume control(VolumeUP,VolumeDOWN and MUTE), so I created this script:

#include "SoundGetSetQuery.au3"
Global $bState=False,$aIcon[4]=["low.ico","med.ico","max.ico","mute.ico"]
$iVolume=_SoundGet(0, "dSpeakers", 1, "Volume")
If $iVolume<=33 Then TraySetIcon($aIcon[0])
If $iVolume>33 And $iVolume<=66 Then TraySetIcon($aIcon[1])
If $iVolume>66 And $iVolume<=100 Then TraySetIcon($aIcon[2])
HotKeySet("{PGUP}","up");VolumeUP
HotKeySet("{PGDN}","down");VolumeDOWN
HotKeySet("{INS}","mute");VolumeMUTE
Func up()
If $bState==False Then
$iVolume=_SoundGet(0, "dSpeakers", 1, "Volume")
Send("{VOLUME_UP}")
If $iVolume<=33 Then TraySetIcon($aIcon[0])
If $iVolume>33 And $iVolume<=66 Then TraySetIcon($aIcon[1])
If $iVolume>66 And $iVolume<=100 Then TraySetIcon($aIcon[2])
EndIf
EndFunc
Func down()
If $bState==False Then
$iVolume=_SoundGet(0, "dSpeakers", 1, "Volume")
Send("{VOLUME_DOWN}")
     If $iVolume>=1 And $iVolume<=33 Then TraySetIcon($aIcon[0])
If $iVolume>33 And $iVolume<=66 Then TraySetIcon($aIcon[1])
If $iVolume>66 And $iVolume<=100 Then TraySetIcon($aIcon[2])
If $iVolume==0 Then TraySetIcon($aIcon[3])
EndIf
EndFunc
Func mute()
If $bState==True Then
$iVolume=_SoundGet(0, "dSpeakers", 1, "Volume")
Send("{VOLUME_MUTE}")
If $iVolume>=1 And $iVolume<=33 Then TraySetIcon($aIcon[0])
If $iVolume>33 And $iVolume<=66 Then TraySetIcon($aIcon[1])
If $iVolume>66 And $iVolume<=100 Then TraySetIcon($aIcon[2])
If $iVolume==0 Then TraySetIcon($aIcon[3])
$bState=False
Else
Send("{VOLUME_MUTE}")
TraySetIcon($aIcon[3])
$bState=True
EndIf
EndFunc
While True
Sleep(10)
WEnd

Here you can find out the script with the original indentation: http://pastebin.com/cCerHina

I attached the icon in this post.

The include "SoundGetSetQuery.au3" can be found here:

I chose the keys "PGUP","PGDN" and "INS" because I use them rare.

I extracted the icons from this iconset: http://www.iconarchive.com/show/oxygen-icons-by-oxygen-icons.org.1.html

icons.7z

Edited by mihaibr

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0