AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Swapper 1.0 Easily switch sound devices!

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Gosugenji



Joined: 07 May 2008
Posts: 35
Location: In your Internets

PostPosted: Wed Jul 02, 2008 6:22 pm    Post subject: Swapper 1.0 Easily switch sound devices! Reply with quote

Say you have a pc speaker, and a usb headset like in my case Smile

swapper 1.0 can swap output, mic, and midi lines if you want.

Before I launch my game, i usually swap sound devices manually. That takes about 3-5 minutes.

With swapper 1.0 it does it in 1-2 seconds! WOW!

swapper also displays the current devices for the scripts tool tip.

update!-
Fixed the tray not updating correctly Smile
added a beep after to confirm output change

Code:

#persistent

window=Sounds and Audio Devices Properties
run, RunDll32.exe shell32.dll`,Control_RunDLL mmsys.cpl`,`,2
winwait ,%window%
ControlGet ,outputs, List,, ComboBox1,%window%
Loop , Parse, outputs, `n
{
  outputs%a_index%=%a_loopfield%
  outmax=%a_index%
}
ControlGet ,inputs, List,, ComboBox2,%window%
Loop , Parse, inputs, `n
{
  inputs%a_index%=%a_loopfield%
  inmax=%a_index%
}
ControlGet ,midis, List,, ComboBox3,%window%
Loop , Parse, midis, `n
{
  midis%a_index%=%a_loopfield%
  midimax=%a_index%
}
controlgettext,outputs,ComboBox1,%window%
controlgettext,inputs,ComboBox2,%window%
controlgettext,midis,ComboBox3,%window%
winactivate , %window%
send ,{enter}

Menu , Settings, add, swap output, swapoutput
Menu , Settings, add
Menu , Settings, add, swap input, swapinput
Menu , Settings, add
Menu , Settings, add, swap midi, swapmidi

;Menu , tray, nostandard
Menu , tray, tip, Swapper 1.0`nOutput Device:%outputs%`nInput Device:%inputs%`nMidi Device:%midis%
Menu , tray, add, Swapper 1.0, blank
Menu , tray, add, swap, :Settings
Menu , tray, add, Reload, Reload
Menu , tray, add  ; Creates a separator line.
Menu , tray, add, Exit, Exit
return

blank:
return

Reload:
reload
return

Exit:
exitapp
return

swap:
run , RunDll32.exe shell32.dll`,Control_RunDLL mmsys.cpl`,`,2
winwait , %window%
winactivate , %window%
swap1:=%swap%1
swap2:=%swap%2
controlgettext,real,%swapnum%,%window%  ;,Sounds and Audio Devices Properties

if real = %swap2%
{
control ,ChooseString,%swap1%,%swapnum%,%window%
%swap%=%swap1%
Menu , tray, tip, Swapper 1.0`nOutput Device:%outputs%`nInput Device:%inputs%`nMidi Device:%midis%
send , {Enter}   
sleep 2600
winwaitnotactive,%window%
if beep = on
{
SoundPlay, %A_WinDir%\Media\ding.wav
}
return
}
if real = %swap1%
{
control ,ChooseString,%swap2%,%swapnum%,%window%
%swap%=%swap2%
Menu , tray, tip, Swapper 1.0`nOutput Device:%outputs%`nInput Device:%inputs%`nMidi Device:%midis%
send , {Enter}
winwaitnotactive,%window%
if beep = on
{
SoundPlay, %A_WinDir%\Media\ding.wav
}

return
}
return

swapoutput:
swap=outputs
beep=on
swapnum=ComboBox1
gosub ,swap
return

swapinput:
swap=inputs
beep=off
swapnum=ComboBox2
gosub ,swap
return

swapmidi:
swap=midis
beep=off
swapnum=ComboBox3
gosub ,swap
return


Last edited by Gosugenji on Thu Jul 03, 2008 2:48 am; edited 2 times in total
Back to top
View user's profile Send private message
Rhys



Joined: 17 Apr 2007
Posts: 722
Location: Florida

PostPosted: Wed Jul 02, 2008 6:46 pm    Post subject: Reply with quote

I look forward to testing this on my laptop when I get home... Thanks!
_________________
[Join IRC!]
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group