#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon="spkr.ico" #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_Comment=By: Careca #AutoIt3Wrapper_Res_Description=Audio Player #AutoIt3Wrapper_Res_Fileversion=1.3 #AutoIt3Wrapper_Res_SaveSource=y #AutoIt3Wrapper_Res_Icon_Add="spkr.ico" #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #AutoIt3Wrapper_Run_Tidy=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;========================================================================= DirCreate(@TempDir & '\SSO') FileInstall("spkr.ico", @TempDir & "\SSO\spkr.ico") FileInstall("Info.jpg", @TempDir & "\SSO\Info.jpg") FileInstall("SwitchSoundOutput.au3", @TempDir & "\SSO\SwitchSoundOutput.au3") #include #include #include #include #include #include Opt("TrayMenuMode", 1) Opt("TrayIconHide", 0) Opt("GUIResizeMode", 1) Opt("TrayIconDebug", 1) Opt("TrayAutoPause", 0) Opt("GUIOnEventMode", 1) Opt("MustDeclareVars", 1) Opt("GUIEventOptions", 1) Opt("TrayOnEventMode", 1) Opt("ExpandEnvStrings", 1) Opt("WinDetectHiddenText", 1) Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client ;Gui Local $GUI, $Frm_main, $Label1, $Button1, $hChildWin, $Title, $Text, $Pic ;Tray Local $PLTray, $PSTray, $STTray, $NTray, $PTray, $CTTray, $ExitItem ;Vars Local $WinState, $Spin2, $Ini, $TextIniRead, $RegTSmallIco, $MousePosX, $MousePosY ;========================================================================= TraySetIcon("spkr.ico") $Ini = @TempDir & '\SSO\Defs.ini' RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Multimedia\Audio\DeviceCpl", "ShowHiddenDevices", "REG_DWORD", 0) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Multimedia\Audio\DeviceCpl", "ShowDisconnectedDevices", "REG_DWORD", 0) If FileExists($Ini) Then $TextIniRead = IniRead($Ini, "LastOperation", "Selected", "Load Failed!") If $TextIniRead = 'Device2' Then Device1() EndIf If $TextIniRead = 'Device1' Then Device2() EndIf Show() Exit Else MsgBox(64, 'Warning', 'No ini has been found!' & @CRLF & 'This is considered the first start of application.') Preparation() IniWrite($Ini, "LastOperation", "Selected", 'Device1') EndIf ;============================================================================= Func Device1() Run("rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,0") WinWaitActive("Sound", "Select a playback device") Send("{Down 2}") ControlClick("Sound", "", 1002) Sleep(150) ControlClick("Sound", "OK", 1) IniWrite($Ini, "LastOperation", "Selected", 'Device1') EndFunc ;==>Device1 ;============================================================================= Func Device2() Run("rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,0") WinWaitActive("Sound", "Select a playback device") Send("{Down 1}") ControlClick("Sound", "", 1002) Sleep(150) ControlClick("Sound", "OK", 1) IniWrite($Ini, "LastOperation", "Selected", 'Device2') EndFunc ;==>Device2 ;============================================================================= Func Preparation() Run("rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,0") WinWaitActive("Sound", "Select a playback device") MsgBox(64, 'Instructions', 'Arrange the 2 devices so that they are on top of the list' & @CRLF & 'For that, you can hide the disabled devices.. etc.') EndFunc ;==>Preparation ;============================================================================= Func Show() ;========================================================================= $hChildWin = GUICreate("Child GUI", 360, 74, @DesktopWidth - 360, @DesktopHeight + 300, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST, $GUI) $Title = GUICtrlCreateLabel('Title', 80, 10, 275, 25) GUICtrlSetFont($Title, 14, 900, 0, 'Arial', 5) GUICtrlSetColor($Title, 0xFFFFFF) GUICtrlSetBkColor($Title, 0x1F1F1F) $Text = GUICtrlCreateLabel('Text', 80, 35, 275, 42, $SS_LEFT) GUICtrlSetFont($Text, 9, 600, 0, 'Arial', 5) GUICtrlSetColor($Text, 0x707070) GUICtrlSetBkColor($Text, 0x1F1F1F) GUISetState(@SW_SHOW, $hChildWin) GUISetBkColor(0x1F1F1F, $hChildWin) $Pic = GUICtrlCreatePic(@TempDir & '\SSO\Info.jpg', 1, 1, 72, 72) GUICtrlSetData($Title, 'SSO Switcher') GUICtrlSetData($Text, 'Switched Device!') ;============================================================================= $RegTSmallIco = RegRead('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced', 'TaskbarSmallIcons') If $RegTSmallIco = 1 Then WinMove($hChildWin, '', @DesktopWidth - 360, @DesktopHeight - 104, 360, 75, 1) Else WinMove($hChildWin, '', @DesktopWidth - 360, @DesktopHeight - 114, 360, 75, 1) EndIf Sleep(2000) WinClose($hChildWin) EndFunc ;==>Show ;============================================================================= Do Sleep(10000) Quit() Until GUIGetMsg() = $GUI_EVENT_CLOSE ;============================================================================= Func Quit() Exit EndFunc ;==>Quit ;=============================================================================