Jump to content

On Screen Display (Volume)


zone97
 Share

Recommended Posts

i made a simple one not long ago aswell ...

#NoTrayIcon

HotKeySet("{NUMPADADD}", "Volume_Add")
HotKeySet("{NUMPADSUB}", "Volume_Sub")
HotKeySet("^e", "_Quit")

func Volume_Prog_Bar()
    $Volume_Bar = ""
    for $i = 1 to 10 step 1
        if Volume_Get() / 10 >= $i Then
            $Volume_Bar &= "|"
        Else
            $Volume_Bar &= "-"
        endif
    next
    $Volume_Display = Volume_Get() & "% " & $Volume_Bar
    Return $Volume_Display
EndFunc

func Volume_Add()
    if Volume_Get() < 100 then
        SoundSetWaveVolume(Volume_Get() + 10)
        ToolTip(Volume_Prog_Bar())
        Sleep(1000)
        ToolTip('')
    EndIf
EndFunc

func Volume_Sub()
    if Volume_Get() > 0 then
        SoundSetWaveVolume(Volume_Get() - 10)
        ToolTip(Volume_Prog_Bar())
        Sleep(1000)
        ToolTip('')
    EndIf
EndFunc

Func Volume_Get()
    Local $WaveVol = -1, $p, $ret
    Const $MMSYSERR_NOERROR = 0
    $p = DllStructCreate ("dword")
    If @error Then
        SetError(2)
        Return -2
    EndIf
    $ret = DllCall("winmm.dll", "long", "waveOutGetVolume", "long", -1, "long", DllStructGetPtr ($p))
    If ($ret[0] == $MMSYSERR_NOERROR) Then
        $WaveVol = Round(Dec(StringRight(Hex(DllStructGetData ($p, 1), 8), 4)) / 0xFFFF * 100)
    Else
        SetError(1)
    EndIf
    $Struct=0
    Return $WaveVol
EndFunc

Func _Quit()
    MsgBox(0, "Exit", "CVC Closed")
    Exit
EndFunc

While 1
    Sleep(100)
WEnd

Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...