Jump to content
Sign in to follow this  
Mikesch

Getting standard sound output device (Win7)

Recommended Posts

Mikesch

I'd like to know if there's a method of retrieving the current sound output device in Win 7.

It's easy in Win XP, but the dialog boxes in Win 7 are not that accessible, at least not for me (or the Au3InfoTool).

I made two scripts which simply select the first/second device in the list. That works fine, but I'd like to add a small tooltip which displays the new selection.

Thanks in advance,

Mike

Edited by Mikesch

Share this post


Link to post
Share on other sites
Mikesch

Sure. It doesn't even try to read the device name yet, it just does the switching. Anyway, it works with Win 7, (32 & 64)

;select Audio Device from device list; 0-based

$ref = 0 ;selects 1st sound device, 1=second device...

$SoundPID = Run("control mmsys.cpl")
Global $hWnd
$aWinList = WinList()

For $i = 1 To $aWinList[0][0]
    If WinGetProcess($aWinList[$i][0]) = $SoundPID Then
        $hWnd = $aWinList[$i][1]
        ExitLoop
    EndIf
Next
WinWait($hWnd, "")
Sleep(300)

ControlListView($hWnd, "", "SysListView321", "Select", $ref)
Sleep(300)

ControlClick($hWnd, "", "Button2")
ControlClick($hWnd, "", "Button4")

Regards,

Mike

Share this post


Link to post
Share on other sites
Mikesch

Thanks, but this is not about debugging the code I have, it works fine.

I just want to know how I can get the name of the device which is selected after the script has done its job. Maybe reading a registry key or the like. The dialog is not very talkative ;-)

Mike

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.