Login / Register
▼
Binary Fortress
Binary Fortress Software
CheckCentral
ClipboardFusion
CloudShow
DisplayFusion
FileSeek
HashTools
LogFusion
Notepad Replacer
Online Base64 Decoder
Online Base64 Encoder
Online JSON Formatter
ShellSend
TrayStatus
VoiceBot
WallpaperFusion
Window Inspector
More Apps...
DisplayFusion
CheckCentral
CloudShow
ClipboardFusion
FileSeek
VoiceBot
WallpaperFusion
Home
▼
Download
Download
Change Log
Download Beta
Beta Change Log
License (EULA)
▼
Features
Features
Incredible Desktop Wallpaper
Monitor Configuration
Monitor Splitting
Powerful Functions
Triggers
Multi-Monitor Taskbars
Useful Windows 10 Tweaks
Useful Windows 8 Tweaks
Windows Lock Screen
Multi-Monitor Screen Savers
Monitor Fading
Window Snapping
Window Management
Mouse Management
Alt+Tab Handler
Window Position Profiles
Desktop Icon Profiles
Remote Control
Available in dozens of Languages
Easy Administration
Free vs Pro
Purchase
Screenshots
Languages
▼
Help
Help Guide
FAQ
Discussions
Contact Us
Find My License
Mailing Address
Advanced Settings
Scripted Functions (Macros)
Display
Fusion
WARNING: You currently have Javascript disabled!
This website will not function correctly without Javascript enabled.
Title
Message
OK
Confirm
Yes
No
Select Audio-Device (Yes/No Dialog)
Return to DisplayFusion Scripted Functions (Macros)
Description
I use this function to toggle between two audio-devices with minimum UI-Interaction (just Y/N-Selection instead of having to deal with Listboxes etc.) You will need to update the code and enter the names of your devices - fear not: there's even commented code to show the names, in case you don't know them!
Language
C# (.Net)
Minimum Version
9.5+
Created By
MBaas
Contributors
-
Date Created
Jun 10, 2019
Date Last Modified
Jun 10, 2019
Scripted Function (Macro) Code
Copy
Select All
Toggle Line Wrapping
using System; using System.Drawing; using System.Linq; public static class DisplayFusionFunction { public static void Run () { //*** Typical usage scenario is to toggle between 2 devices - so make sure to enter the names of your devices here: (if you have problems getting them correctly, try uncommenting line 14-17) string[] myPreferredDevices = { "Speakers/Headphones (Realtek(R) Audio)", "Lautsprecher (5- Sennheiser USB headset)" }; string[] devList = BFS.Audio.GetPlaybackDevices (); string foo = string.Concat ("Devices", String.Join (",", devList.ToArray ())); string currDevice = BFS.Audio.GetDefaultPlaybackSounds (); string[] filteredList = devList.Intersect (myPreferredDevices, StringComparer.OrdinalIgnoreCase).ToArray (); // Diagnosis to see name of devices etc. //foo = string.Concat(foo, "\n"); //foo = string.Concat(foo, String.Join("," , filteredList.ToArray())); // BFS.Dialog.ShowMessageError(foo); string selectedAudioDevice = ""; bool doIt = false; if (filteredList.Length == 0) { BFS.Dialog.ShowMessageError ("No Audio Devices Found!"); } else if (filteredList.Length == 2) { int i = Array.IndexOf (filteredList, currDevice); int j = (i == 0) ? 1 : 0; string msg = String.Concat ("Press Yes to switch to device ", filteredList[j]); doIt = BFS.Dialog.GetUserConfirm (msg); selectedAudioDevice = filteredList[j]; } else { // Prompt to select an audio device selectedAudioDevice = BFS.Dialog.GetUserInputList ("Please select an audio device:", devList); doIt = true; } if (doIt) { // Set the selected device as the default playback device BFS.Audio.SetDefaultPlaybackSounds (selectedAudioDevice); // Set the selected device as the default communication device BFS.Audio.SetDefaultPlaybackCommunications (selectedAudioDevice); } } }
Copyright © 2007-2021 Binary Fortress Software
•
News
•
Discussions
•
FAQ
•
Support
•
Privacy
•
ToS
•
Get DisplayFusion Merch