AppleScript returns "No user interaction"

I tried calling a simple message console from the console:

osascript -e "display dialog \"hello\"" 

but it returns:

 execution error: No user interaction allowed. (-1713) 

Is there a workaround?

EDIT:

Workaround: tell application "AppleScript Runner" to display dialog "Hello"

+6
source share
2 answers

See this answer , it contains an example that works from the console.

-6
source

You can specify a background process, such as SystemUIServer, to display a dialog box. A previously focused window does not return focus after closing the default dialog box. System events and AppleScript Runner may have slight delays if they have not been executed before.

 answer=$(osascript -e 'try tell application "SystemUIServer" set answer to text returned of (display dialog "" default answer "") end activate app (path to frontmost application as text) answer end' | tr '\r' '\n') [[ -z "$answer" ]] && exit 

You can also say that the application on the front panel displays a dialog box, but it is often a bit slower. The dialog is not displayed immediately if the application does not respond. If MPlayer OS X is in front, text dialogs do not accept any keyboard input.

 answer=$(osascript -e 'try tell application (path to frontmost application as text) text returned of display dialog "" default answer "" end end' | tr '\r' '\n') [[ -z "$answer" ]] && exit 
+8
source

Source: https://habr.com/ru/post/922402/


All Articles