Jump to content
Sign in to follow this  
CodyBarrett

VolumeControl

Recommended Posts

CodyBarrett

okay.. so my Wireless Keyboard has a volume control on it, and it died (maybe the batteries just died im not sure) but anyway, i decided to make this FOR MOSTLY every other keyboard.

its a rather simple script, and i have searched for a GetMasterVolumePercent() function or something like it... but decided to do it this way

my volume using VOLUME_UP and VOLUME_DOWN commands, is a max of 25... im not sure if thats on everyone elses? but i used that to control it. check it out.

edit: unneeded characters

edit2: i looked through Volly's mastervolume UDF and i added Audio.au3 i have both the include and the main script in the same Dir... feel free to change it if you want to.

#include 'Audio.au3' ;this is in the same DIR as the script... if you do not have Audio then Download it from the forums... it is Volly's UDF .
#NoTrayIcon
HotKeySet ('^{PGUP}', '_VOLUP')
HotKeySet ('^{PGDN}', '_VOLDOWN')
HotKeySet ('^{HOME}', '_VOLMUTE')
HotKeySet ('^{END}', '_EXIT')
$value = _SoundGetMasterVolume () ;Thank you Volly
$PopUP = 0
While 1
    Sleep (100)
WEnd
Func _POPUP ()
    Local $dW = @DesktopWidth, $dH = @DesktopHeight
    Local $x = ($dW / 2), $y = ($dH / 15), $yp = ($dH * (7/8))
    $PopUP = GUICreate ('', $x,$y, -1, $yp,BitOR(0x08000000,0x80000000, 0x10000000),0x00000100,WinGetHandle ('Program Manager',''))
    GUICtrlCreateLabel ('',0,0,($x * ($value / 100)),($y / 2))
    GUICtrlSetBkColor (-1,0x0000DF)
    GUICtrlSetState (-1, 128)
    GUICtrlCreateLabel ('',0,($y / 2),($x * ($value / 100)),($y / 2))
    GUICtrlSetBkColor (-1, 0x0000B7)
    GUICtrlSetState (-1, 128)
    GUISetBkColor (0x0,$PopUP)
    WinSetOnTop ($PopUP,'',1)
    GUISetState ()
    WinSetTrans ($PopUP,'',220)
EndFunc
Func _SetData ()
    ControlMove ($PopUP,'','Static1',0,0,((@DesktopWidth / 2) * ($value / 100)),((@DesktopHeight /15) / 2))
    ControlMove ($PopUP,'','Static2',0,((@DesktopHeight / 15) / 2),((@DesktopWidth / 2) * ($value / 100)),((@DesktopHeight /15) / 2))
EndFunc
Func _VOLDOWN ()
    If $value = 0 Then Return
    If Not WinExists ($PopUP,'') Then 
        _POPUP ()
    Else
        _SetData ()
    EndIf    
    $value = $value - 1
    _SoundSetMasterVolume ($value) ;Thank you Volly
    Sleep (3000)
    GUIDelete ($PopUP) 
EndFunc
Func _VOLMUTE ()
    Send ('{VOLUME_MUTE}')
EndFunc
Func _VOLUP ()
    If $value = 100 Then Return
    If Not WinExists ($PopUP,'') Then 
        _POPUP ()
    Else
        _SetData ()
    EndIf    
    $value = $value + 1
    _SoundSetMasterVolume ($value) ;Thank you Volly
    Sleep (3000)
    GUIDelete ($PopUP)    
EndFunc
Func _EXIT ()
    Exit
EndFunc
Edited by CodyBarrett

Share this post


Link to post
Share on other sites
Yashied

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.