Estoy tratando de hacer un Applescript que inicie un conjunto diferente de aplicaciones dependiendo de la entrada del usuario. Sin embargo, no compilará. ¿Qué tiene de malo?

0

Hice un AppleScript simple que inicia un conjunto diferente de aplicaciones dependiendo de la entrada del usuario. Soy nuevo en AppleScript y está ajustado de un grupo que encontré en Internet, modificado para mi uso. Se incluye a continuación.

Qué debe hacer: los botones 2 y 3 simplemente inician varios conjuntos de aplicaciones, mientras que el botón 1 comprueba si Spotify se está ejecutando y, si lo está, cambia a él. Si no lo está, abre 3 aplicaciones (incluyendo Spotify).

Sin embargo, aparece un "Fin de línea esperado, etc., pero se encontró el final de la secuencia de comandos". error al compilar. Aquí está el guión. ¿Qué tiene de malo?

set question to display dialog "What do you want to launch?" buttons {"Spotify", "MiniPlayer", "Remote"} default button 1
set answer to button returned of question

if answer is equal to "Spotify" then
    set myAppName to "Spotify"
    set isRunning to false
    tell application "System Events"
        if exists process myAppName then
            set isRunning to true
        end if
    end tell
    if isRunning is true then
        tell application myAppName to activate
    else
        tell application "Spotify" to activate
        tell application "Spotifree" to activate
        tell application "Spotify Notifications" to activate
    end if
end if
if answer is equal to "MiniPlayer" then
    tell application "MiniPlayer" to activate
end if
if answer is Equal to "Remote" then
    set question to display dialog "What remote do you want to launch?" buttons {"IR Remote", "Android", "Both"} default button 2
set answer to button returned of question
    if answer is equal to "IR Remote" then
    tell application SpotifyIrRemote to activate    
    if answer is equal to "Android"
        tell application RemotelessHelper to activate   
    if answer is equal to "Both"
        tell application SpotifyIrRemote to activate
        tell application RemotelessHelper to activate
    end if
end if
    
pregunta Johnny 28.04.2014 - 15:25

1 respuesta

0

Te estás perdiendo un montón de end if s y 2 then .

set question to display dialog "What do you want to launch?" buttons {"Spotify", "MiniPlayer", "Remote"} default button 1
set answer to button returned of question

if answer is equal to "Spotify" then
    set myAppName to "Spotify"
    set isRunning to false
    tell application "System Events"
        if exists process myAppName then
            set isRunning to true
        end if
    end tell
    if isRunning is true then
        tell application myAppName to activate
    else
        tell application "Spotify" to activate
        tell application "Spotifree" to activate
        tell application "Spotify Notifications" to activate
    end if
end if

if answer is equal to "MiniPlayer" then
    tell application "MiniPlayer" to activate
end if

if answer is equal to "Remote" then
    set question to display dialog "What remote do you want to launch?" buttons {"IR Remote", "Android", "Both"} default button 2
    set answer to button returned of question
    if answer is equal to "IR Remote" then
        tell application SpotifyIrRemote to activate
    end if
    if answer is equal to "Android" then
        tell application RemotelessHelper to activate
    end if
    if answer is equal to "Both" then
        tell application SpotifyIrRemote to activate
        tell application RemotelessHelper to activate
    end if
end if
    
respondido por el Matthieu Riegler 28.04.2014 - 15:58

Lea otras preguntas en las etiquetas