Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save karawitan/4655056ea1fa6db6db88f7b9a3eb38fb to your computer and use it in GitHub Desktop.
Save karawitan/4655056ea1fa6db6db88f7b9a3eb38fb to your computer and use it in GitHub Desktop.
macosx audio hijack script to acknoledge "missing audio device" popup

Macosx: Audio Hijack script to acknowledge "missing audio device" popup

To programmatically acknowledge or handle a "missing audio device" popup in macOS when using Audio Hijack, you can use AppleScript or a shell script to automate certain responses, though there are limitations depending on the nature and context of the popup.

osascript -e 'tell application "System Events"' -e 'tell process "Audio Hijack"' -e 'try' -e 'click button 1 of (first window whose subrole is "AXDialog")' -e 'end try' -e 'end tell' -e 'end tell'

You may Save this as a .scpt file and run it with Script Editor or osascript from Terminal.

If you hit the error:

194:198: execution error: System Events got an error: osascript is not allowed assistive access. (-1728)

It means that your script is trying to access UI elements via the System Events application, but macOS is blocking it for security reasons. This is a common issue when automating GUI interactions on macOS.

How to Fix

Grant Assistive Access to Terminal (or your script runner):

  1. Open System Settings (formerly System Preferences).
  2. Go to Privacy & Security.
  3. Select Accessibility (or Privacy > Accessibility in some macOS versions).
  4. Click the + button and add the Terminal app (or your terminal emulator, like iTerm).
  5. If you are running the script from another app (like a cron job or a launcher), you may need to add that app instead.

After granting access, try running your script again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment