Jump to content
Sign in to follow this  
pitcherj

Volume Indicator

Recommended Posts

pitcherj

Is there a way I can retrieve the current volume as a percentage or in some other format? I'm looking to create a volume indicator which appears when the system volume is changed. I can't seem to find anything but a way to set the volume with SoundSetWaveVolume.

Share this post


Link to post
Share on other sites
Gif

Is there a way I can retrieve the current volume as a percentage or in some other format? I'm looking to create a volume indicator which appears when the system volume is changed. I can't seem to find anything but a way to set the volume with SoundSetWaveVolume.

well its a bit difficult , i dont think you cn do that because the volume is changed on the speakers and the computer doesnt take any action in the changing of the volume

Share this post


Link to post
Share on other sites
GaryFrost

well its a bit difficult , i dont think you cn do that because the volume is changed on the speakers and the computer doesnt take any action in the changing of the volume

the user is not talking about the volume knob on the speakers.

The master volume on the volume control, and yes it is possible, a search should reveal it has been done before.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
pitcherj

Well, I've tried using the script referred to in this post: http://www.autoitscript.com/forum/index.ph...rt=#entry338780, however I was unable to even get the base script to change the volume. Windows Vista has a completely re-designed mixer and apparently you can no longer hook into the dll file as that script does (even if the executable is running in windows XP compatability mode).

Jacob

Share this post


Link to post
Share on other sites
pitcherj

According to the comments in that script it only functions when Windows Media Player is open.

; Notes ........: Does Not Affect System/Wave Volumes!!

I need something that can display the main system volume when it changes.

Edited by pitcherj

Share this post


Link to post
Share on other sites
pitcherj

Unfortunately, I ended up going with a program someone already wrote. I got to the point of spending so much time trying to come up with a solution on my own that it wasn't even worth it anymore.

Share this post


Link to post
Share on other sites
FreeFry

Just to add to this, here is how I did it:

Opt("WinTitleMatchMode", 4)

DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1) ; A workaround to get it to work on Windows XP 64bit, I'm not sure if this have been fixed or not by now..

Global $pID = 0
Global $WindowHandle = 0
Global $ControlHandle1 = 0
Global $ControlHandle2 = 0

Global $Muted = False

Global Const $TBM_GETPOS = 0x400
Global Const $TBM_SETPOS = 0x405
Global Const $WM_VSCROLL = 0x115

$g_szVersion = "Volume Control Fixer v1.1"
If WinExists($g_szVersion) Then Exit
AutoItWinSetTitle($g_szVersion)

While 1
    
    If Not WinExists($WindowHandle) Then
        _GetHandles()
    Else
        
        $data1 = DllCall("user32.dll", "int", "SendMessage", "hwnd", $ControlHandle1, "int", $TBM_GETPOS, "int", 0, "int", 0)
        $data2 = DllCall("user32.dll", "int", "SendMessage", "hwnd", $ControlHandle2, "int", $TBM_GETPOS, "int", 0, "int", 0)
        
        If $data1[0] <> $data2[0] Then
            DllCall("user32.dll", "int", "SendMessage", "hwnd", $ControlHandle2, "int", $TBM_SETPOS, "int", True, "long", $data1[0])
            DllCall("user32.dll", "int", "SendMessage", "hwnd", $WindowHandle, "int", $WM_VSCROLL, "int", $SB_LINEDOWN, "int", $ControlHandle2)
        ElseIf ControlCommand($WindowHandle, "", "Button2", "IsChecked") And Not $muted Then ; Sound is muted
            ControlCommand($WindowHandle, "", "Button4", "Check")
            TrayTip("Muted!", "Sound Muted!", 0)
            $muted = True
        ElseIf Not ControlCommand($WindowHandle, "", "Button2", "IsChecked") And $muted Then ; Sound is unmuted
            ControlCommand($WindowHandle, "", "Button4", "UnCheck")
            TrayTip("Unmuted!", "Sound Unmuted!", 0)
            $muted = False
        EndIf
    
    EndIf
    
    Sleep(100)
    
WEnd

Func OnAutoItExit()
    
    If ProcessExists($pID) Then
        ProcessClose($pID)
    EndIf
    
EndFunc   ;==>OnAutoItExit

Func _GetHandles()
    
    $pID = Run(@SystemDir & "\sndvol32.exe", @SystemDir);, @SW_HIDE)
    
    If Not WinWait("classname=Volume Control", "", 7500) Then
        MsgBox(0, "Error!", "Volume Control Could not be opened! Exiting..")
        Exit
    EndIf
    
    $WindowHandle = WinGetHandle("classname=Volume Control")
    $ControlHandle1 = ControlGetHandle($WindowHandle, "", 1001)
    $ControlHandle2 = ControlGetHandle($WindowHandle, "", 2001)
    
EndFunc

I used this when I had a keyboard with volume control buttons on it, but it did only change the wave volume, and I wanted it to change "all" volume controls, so I made it lock the Wave volume sliders with the System Volume sliders. :)

Edited by FreeFry

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  

×