Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have the applescript which will displays menu list and allow user to select menu items etc. It runs fine by itself. And now I try to run it in python. I get the No user interaction allowed. (-1713) error.

I looked online. I tried the following:

  1. add on run function in the same applescript, so what i did is just add the main into the run

    on run tell application “AppleScript Runner” main() end tell end run

  2. i tried to run the above in python import os def main(): os.system ('osascript -e "tell application "ApplesScript Runner" do script /Users/eee/applescript/iTune.scpt end tell"')

    if name == 'main': main() Neither way works. Can anyone tell me how to do this correctly?

share|improve this question
up vote 8 down vote accepted

That's a common mistake. When you run a script using OSAScript from a shell, as you are doing, then you must tell an application to show any "display dialogs" or "choose list dialogs" or anything that requires user interaction. OSAScript can't show them so tell an app like the Finder to show them. Use code like this...

tell application "Finder"
    activate
    display dialog "Now it works!"
end tell

Or from the command line notice this won't work...

osascript -e 'display dialog "Now it will not work."'

But this will work since we tell the Finder to do it...

osascript -e 'tell application "Finder"' -e 'activate' -e 'display dialog "Now it works!"' -e 'end tell'

So bottom line is that somewhere in your iTune.scpt you are displaying a dialog. In that script just tell iTunes or the Finder to display them.

share|improve this answer
    
Thanks!!! It works now! – Fish OnTray Nov 21 '12 at 17:15
    
Thank you; that solved my problem also! x – Danny Sep 24 '13 at 11:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.