Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

User Image
h0rn3t920
5 discussion posts
Hello,
Is there a custom script someone can provide me to use with triggers, if possible? I am looking to utlize triggers to Change my audio device when my monitor profile changes. But, I want them to only change if a audio device is disconnected. Essentially, If my Bluetooth Headphones are connected, I dont want any Audio device changes. If they are disconnected, I want an audio device selected as default audio source dependent on which profile it has loaded.

I would also like a trigger if possible to run when the device is disconnected.

Let me know if someone can help provide this or if this may not be possible. Thank you!
Dec 12, 2022 (modified Dec 12, 2022)  • #1
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
I've attached a script below that should do this for you. You can import it via the DisplayFusion Settings > Functions > Import Scripted Function.

You can set the name of your bluetooth headphones on line 15, and set the name of the audio device you want it changed to if those headphones aren't connected on line 27. You can then create a trigger that uses the "Monitor Profile Changed" event, and add this script into the actions pane. You can create multiple copies of the script changing to different devices if you would like, depending on which monitor profile you want loaded.

Hope that helps!
• Attachment: Set Audio Device.dfscript [2,766 bytes]
Dec 13, 2022 (modified Dec 13, 2022)  • #2
User Image
h0rn3t920
5 discussion posts
Hey, Thanks for this! It works great! I have a few additional requests now that I have used it, let me know if this is possible.

1. Can I also have it default the communications device as well as the playback device?
2. If I disconnect my headphones, it goes back to the most recent default device. Is there a way for it to go back to the right default device based on which display configuration I may be on?
For instace: If I am on Monitor Profile 1 and switch to Profile 2 with my headphones connected, it keeps them connected no problem. That works great! If I turn off the headphones while connected to monitor profile 2 though, It will revert the default to the device used with the previous used profile.

Thank you for your help!
Dec 20, 2022 (modified Dec 20, 2022)  • #3
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
1) Yep, you can add in this line right after line 27:

Code

BFS.Audio.SetDefaultPlaybackCommunications("DeviceNameHere");


2) I can't think of a great way to do this. We don't have an event to fire off an audio device change, so you would need a script that runs in the background and constantly checks to see if the device matches. You might be better off creating a script with a single line that changes the audio device, and add a key combination to manually fire it when you disconnect your device.

Thanks!
Dec 21, 2022  • #4
User Image
h0rn3t920
5 discussion posts
Thanks so much, that did the trick! You guys are very helpful!

What about a script that runs with a button press, checks the Monitor Profile and selects the playback and communication devices based on which profile is active?
Would that work?
Dec 21, 2022 (modified Dec 21, 2022)  • #5
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
Yep that's possible, I've attached a script below that will do that. You can input your monitor profile names and audio device names in the script, and copy the "Else if" section as many times as you would like for each monitor profile you have.

You can also assign audio devices to your montior profiles through the DisplayFusion Monitor Configuration window. It will load them each time the monitor profile is loaded, if that works for you.

Thanks!
Dec 22, 2022  • #6
User Image
h0rn3t920
5 discussion posts
Ok great! Thanks so much. I am going to try this. I used to have it set the audio device by profile which worked but I wanted to include the exception for the headphones.

I have another thing to add on the above discussion regarding the communication device. I did add the script as described below and it does seem to work, but only intermittenly. It runs fine if you run the function, and sometimes fine when you switch profiles. But I am noticing I am switching profiles and only the playback device is switching, not the communication device. Ive checked over it multiple times and it is right/working. Would you have any idea why this would occur and not 100% of the time?
Dec 22, 2022  • #7
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
Strange, maybe it needs a delay in between setting each device. Can you try adding this line right before it tries to change the second device:

Code

BFS.General.ThreadWait(1000);
Dec 22, 2022  • #8
User Image
h0rn3t920
5 discussion posts
The delay did the trick! And the other macro works absolutely fantastic! Thank you so much for your help, Ive gotten it exactly where I want it! This is great.

Happy Holidays!
Dec 23, 2022  • #9
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(-)  Login to Vote(-)