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.
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.
Grant Assistive Access to Terminal (or your script runner):
- Open System Settings (formerly System Preferences).
- Go to Privacy & Security.
- Select Accessibility (or Privacy > Accessibility in some macOS versions).
- Click the + button and add the Terminal app (or your terminal emulator, like iTerm).
- 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.