Any way to use an audiobell

Hi,

Newbie here. I am trying 3 commands on a webpage, and I wish to add a command which basically should be an audio alert. something like C’s \a (audiobell).

Sorry if this is too dumb a question.

I know two options:

  1. Use echo: echo | hello! | #shownotification <= This does not play a sound, but shows a desktop notification

  2. Play sound: You can use executeScript to load and play a website sound file.

executeScript | var audio = new Audio('http://www.storiesinflight.com/html5/audio/shimmer.wav');audio.play();

One line macro that plays the sound:

{
  "Name": "sound",
  "CreationDate": "2019-8-31",
  "Commands": [
    {
      "Command": "executeScript",
      "Target": "var audio = new Audio('http://www.storiesinflight.com/html5/audio/shimmer.wav');audio.play();",
      "Value": ""
    }
  ]
}

An improved solution is to use executeScript _Sandbox so the sound plays even if no website is open in the browser.

This works:

{
  "Name": "sound",
  "CreationDate": "2021-5-11",
  "Commands": [
    {
      "Command": "executeScript_Sandbox",
      "Target": "const audio = new Audio(\"https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3\");\n  audio.play();",
      "Value": "",
      "Description": "Sounds starts playing. ExecuteScript does NOT wait for the sound to stop. "
    },
    {
      "Command": "echo",
      "Target": "MP3 is playing! To stop it, close the UI.Vision IDE",
      "Value": "green",
      "Description": ""
    }
  ]
}
1 Like

I set up my UI Vision with Task Scheduler.
Is there a way for UI Vision to close right after the sound end?

@Plankton solution does not work anymore because const is somehow not supported anymore (see: Error Parsing regex - #2 by ulrich)

@ulrich solution, instead, still works well.