Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

User Image
Ben Anderson5
3 discussion posts
Hello. I'm trying to achieve something that is probably a niche functionality, and may not be even possible.
Basically what I'm after is getting some sort of notification or email alert if an audio device is not available.
My best guess to achieve this is setting an audio device in monitor profile, but if that audio device becomes unavailable then there's no error message. Is this something that's possible?

My use case is I'm using an audio device that is available when plugged in via USB. I want to get an alert if it gets unplugged/unavailable as it's fairly mission cricical that it continues to be plugged in.
Apr 21, 2022  • #1
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
Hi Ben,

We've added a script to our repository called "Show error message if audio device is missing". You can download it via the DisplayFusion Settings > Functions > Scripted Function > Download Scripted Function.

You can adjust the name of the playback device you would like on line 11. You can then either attach a key combination to the script and run it manually when you would like, or create a trigger to have the script run automatically every few minutes.

The script opens a dialog box if the device isn't found, sending an email would be pretty tricky.

Hope that helps!
Apr 22, 2022  • #2
User Image
Ben Anderson5
3 discussion posts
Hi Owen,
Thanks for adding that script, I appreciate it! I got it working. FYI, the description says to modify line 17, not 11.
I was actually after it functioning on recording devices, not playback, but fortunately my device has a playback and recording function so if it's unplugged both functionalities disappear so I can make do with it just doing playback, but if it's easy to add recording monitoring that'd be great.
Since sending the first message I've been able to put together a Powershell script that fires off an email when it's launched. I was able to moify the code a bit and changed line 46 to be
BFS.Application.Start("C:/Users/GCC-Server/Documents/Scripts/Audio_devices_disconnected_email_alert.bat");

The bat file then runs a Powershell script.
So I'm really close to having this working. So stoked!
However I'm running into a few problems. If I set it to trigger the function every few minutes, then the functions keep running and I get more and more of the same functions all running at once.
Is it possible to kill the function off after a period of time or to only have 1 instance of the function running at once?
Ideally I'd want it to check every few minutes for the audio device, and if it's there then just keep monitoring it. If it's not there then trigger the .bat file, and then go back to monitoring. Obviously if the audio device isn't restored promptly I'd get heaps of emails, so somehow limiting it to only trigger the .bat file once a day would be great. Or another potentially simpler option would be that if there is no audio device, open the .bat file and stop the function. I could then set the trigger to run the function once a day, whilst somehow only ever having one instance of the function running at any given time.
Apr 28, 2022 (modified Apr 28, 2022)  • #3
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
Ah whoops, we'll get that description fixed up.

To get the recording devices instead, you can replace the "BFS.Audio.GetPlaybackDevices();" lines, with "BFS.Audio.GetRecordingDevices();".

The script is set to loop forever every 60 seconds (via the thread wait at the end of the script, which can be tweaked to whatever time you would like), so you actually don't need to have it run on a timed trigger. If you set the event to "DisplayFusion Starts", it should run once on boot, and re-loop forever until DisplayFusion is exited.

Thanks!
Apr 29, 2022  • #4
User Image
Ben Anderson5
3 discussion posts
Ok great, I've got it all working how I want it. Thanks for your help!

One last question. Is it possible to check ASIO audio devices?
May 2, 2022 (modified May 2, 2022)  • #5
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
Hi Ben,

If it doesn't show up in the list of audio devices in the DisplayFusion tray menu, it won't be possible to check with a script.

Thanks!
May 3, 2022  • #6
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(1)  Login to Vote(-)