Come sbarazzarsi della conferma di Applescript?

2

Sono un OS X novizio .

Ho un set di Applescript da avviare all'avvio e invece di eseguire automaticamente, devo attivare lo script con una conferma di esecuzione:

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

Come faccio a liberarmi di questo in modo che l'applicazione funzioni senza problemi?

Il seguente file è stato salvato come applicazione.

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
    
posta Nosa Lawani 12.07.2016 - 22:16
fonte

2 risposte

2

Apri il tuo script in Script Editor. Fai un Salva con nome ... (tieni premuto il tasto Opzione e "Duplica" nel menu File cambierà in "Salva con nome ...").

Se salvi lo script come applicazione questa volta, assicurati che la casella "Mostra schermata iniziale" non sia selezionata. Guarda il mio screenshot.

Questo è tutto ciò che c'è da fare. Il tuo vecchio script è stato salvato con l'opzione "Mostra schermata di avvio" selezionata. Ora sai cosa fa questa opzione!

    
risposta data 13.07.2016 - 07:52
fonte
1

Questo non vuole essere una risposta alla tua domanda, è un esempio di come migliorare il tuo codice .

Dopo aver esaminato il tuo codice , le 240 linee di codice che circondano il codice tasto degli eventi di sistema e il ritardo possono essere condensato in 14 righe di codice utilizzando 3 istruzioni ripeti in totale. Imposta una ripetizione 10 volte per ogni codice chiave e una ripetizione 3 volte che la circonda.

Esempio:

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
    
risposta data 13.07.2016 - 14:20
fonte

Leggi altre domande sui tag