Jump to content

Implementing a sound toggle.


bbutle01
 Share

Recommended Posts

Ok, from another forum I found a nice little script that will let me Switch my sound output from speakers to headphone:

The problem is, getting it to the point it's useable is getting pretty ugly.

So, the program takes a parameter, that being the sound device to output to. That is "1" or "2".

So, I wrote a batch file to call my autoit program, that's basicly:

echo off

"c:\program files\sound_control.exe" 1.

Then I wrote another script that does it for 2.

So that's good, now for the hotkey. I was already using ultramon, so i made it map cntrl-alt-shift-1 to one of those, and another for '2'.

Good so far, but it's ugly that it opens the batch file window, then it opens the sound control panel, then it closes them. Just not a very elegant solution.

So I created a shortcut to each of my batch files, told them to run minimized. That's SLIGHTLY better.

So, anyway, I'm working now, but it's ugly. I'm hoping someone here could tell me how to change the original script to just search for a variable in an ini, or registry. If it's '1', then call 2. And vice versa.

I just want to have one hotkey that toggles between my two output devices.

Thanks!

Oh, and obviously I'm not programmer or I would have done this easy task myself.

Thanks

;-----Configuration-----
;The title of the sound config window.
Dim $ConfigWindowTitle = "Sound"
;-----End of configuration----

Dim $ItemNumber = 1
If $CmdLine[0] >= 1 Then ;If we have a parameter...
    $ItemNumber = $CmdLine[1] ;...we should press the button the specified number of times.
EndIf

Run("control mmsys.cpl") ;Run the sound control applet and hide it.

WinWaitActive($ConfigWindowTitle) ;Wait for it to be active before sending keystrokes.

Send("{TAB}{TAB}{TAB}{TAB}") ;Put the focus on the list

For $i = 1 to $ItemNumber Step 1
    Send("{DOWN}")
Next

Send("!s") ;Press Alt + S to set the selected device as the default.
WinClose($ConfigWindowTitle)
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...