Jump to content
Sign in to follow this  

Adjust Sound & Audio Device Properties

Recommended Posts


I want to make a script that can, with a hotkey, adjust sound & audio device properties.

For example, if I right click the speaker icon and choose Adjust Audio Properties

(I'm on WinXP btw), I get that window "Sound and Audio Device Properties" with these







Now I want the script to go to Audio tab and change the Sound playback to "xxxxxx"

(doesn't matter the text, but it's the second value in the drop down list).

I also want the script to go back to the previous value in the same drop down list

with a different hotkey.

Is that possible? I assume it needs to go to registry but I just don't know anything

about registry or how to access and/or manipulate the windows registry.

Thanks a lot for any hints/help!

Share this post

Link to post
Share on other sites

I looked but your script does volume set and get. Am I wrong?

I need to change the device not just the volume...

Share this post

Link to post
Share on other sites

I have a old(dusty) script I made a long time ago, to lock the wave volume to the main volume, it might have something you can use in it:

Opt("WinTitleMatchMode", 4)

DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)

Global Const $pID = Run(@SystemDir & "\sndvol32.exe", @SystemDir, @SW_HIDE)

WinWait("classname=Volume Control")

Global $Muted = False
Global Const $TBM_GETPOS = 0x400
Global Const $TBM_SETPOS = 0x405
Global Const $WM_VSCROLL = 0x115
Global Const $SB_LINEDOWN = 0x1
Global Const $SB_LINEUP = 0x0
Global Const $WindowHandle = WinGetHandle("classname=Volume Control")
Global Const $ControlHandle1 = ControlGetHandle($WindowHandle, "", 1001)
Global Const $ControlHandle2 = ControlGetHandle($WindowHandle, "", 2001)

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

While 1
    If Not WinExists($WindowHandle) Then
        MsgBox(0, "Error!", "sndvol32.exe is not running, exiting")
        $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
;~          If $data1[0] > $data2[0] Then
;~              TrayTip("", "Volume @ " & Int(100-($data1[0]/5)) & "%", 0)
;~              DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $ControlHandle2, "int", $TBM_SETPOS, "int", 1, "int", $data1[0])
;~              DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $WindowHandle, "int", $WM_VSCROLL, "int", $SB_LINEDOWN, "int", $ControlHandle2)
;~          ElseIf $data1[0] < $data2[0] Then
;~              TrayTip("", "Volume @ " & Int(100-($data1[0]/5)) & "%", 0); works, but buggs out sometimes... annoying, therefore removed
;~              DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $ControlHandle2, "int", $TBM_SETPOS, "int", 1, "int", $data1[0])
;~              DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $WindowHandle, "int", $WM_VSCROLL, "int", $SB_LINEUP, "int", $ControlHandle2)
;~          EndIf
            DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $ControlHandle2, "int", $TBM_SETPOS, "int", 1, "int", $data1[0])
            DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $WindowHandle, "int", $WM_VSCROLL, "int", $SB_LINEDOWN, "int", $ControlHandle2)
            If ControlCommand($WindowHandle, "", "Button2", "IsChecked") And Not $muted Then
                ControlCommand($WindowHandle, "", "Button4", "Check")
                TrayTip("Muted!", "Sound Muted!", 0)
                $muted = True
            ElseIf Not ControlCommand($WindowHandle, "", "Button2", "IsChecked") And $muted Then
                ControlCommand($WindowHandle, "", "Button4", "UnCheck")
                TrayTip("Unmuted!", "Sound Unmuted!", 0)
                $muted = False

Func OnAutoItExit()
;~  If WinExists($WindowHandle) Then
;~      WinClose($WindowHandle)
;~  EndIf
    If ProcessExists($pID) Then
EndFunc   ;==>OnAutoItExit

Lots of commented out code, etc. But as I said, it's old. :)

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.