2

I am an OS X novice.

I have an Applescript set to run at boot and instead of running automatically, I have to trigger the script with a run confirmation:

"Press Run to run this script, or Quit to quit"

How do I get rid of this so the application runs seamlessly?

The following file was saved as an application.

tell application "Finder"
    activate
    tell application "Finder" to set pathToSound to (((path to me) & "Contents:Resources:TardisTakeoff.m4a") as string) as alias

    tell application "QuickTime Player" to play (open pathToSound)
end tell

tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)

quit me
  • 1
    It might be more helpful if you'd include the contents of the AppleScript script and how you saved it, e.g, as a script, application bundle or application? The latter is better for automated processes assuming you have no code that requires user input to run. – user3439894 Jul 12 '16 at 20:47
  • How exactly do I embed such a file into my question – Nosa Lawani Jul 12 '16 at 21:20
  • You can copy and paste the code from the AppleScript into your question by clicking the edit link. After you pasted it, highlight the code and press the Code sample button (the curly braces) on the toolbar. And don't forget to state how you originally saved it, e.g, as a script, application bundle or application. – user3439894 Jul 12 '16 at 22:36
2

Open up your script in Script Editor. Do a Save As... (hold Option key down and "Duplicate" in File menu will change to "Save As...").

When you save your script as an application this time, make sure the box that says "Show Startup Screen" is not checked. See my screenshot.

That's all there is to it. Your old script was saved with the "Show startup screen" option checked. Now you know what that option does!

AppleScript save as application without Startup Screen

| improve this answer | |
  • Thank you, the script was not saved as an application in itself but only part of a larger application folder. Due to your detailed answer I was able to solve the problem by opening the application. Upon seeing the startup screen, I pressed file and unchecked show startup screen. Thanks – Nosa Lawani Jul 14 '16 at 18:47
  • I wonder where that option is saved in the application package itself, that you can just change that line instead of having to duplicate the file and delete the original... – DonielF Jul 25 '17 at 23:24
  • I get this confirmation dialog even though I don't have my AppleScript set to show a startup screen. – iconoclast Oct 19 '18 at 20:08
  • It seems holding ctrl while launching the script causes this popup to show. If you have a macro bound to a keyboard shortcut that includes ctrl it will cause it. – hawk Nov 12 '18 at 21:25
1

This is not meant to be an answer to your question, it's an example of how to improve your code.

After reviewing your code, the 240 lines of code surrounding System Events key code and delay can be condensed into 14 lines of code using 3 repeat statements in total. Setup a repeat 10 times statement for each key code and a repeat 3 times statement surrounding it.

Example:

repeat 3 times
    repeat 10 times
        tell application "System Events"
            key code 107
        end tell
        delay (0.1)
    end repeat
    repeat 10 times
        tell application "System Events"
            key code 113
        end tell
        delay (0.1)
    end repeat
end repeat
| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .