0 votos

Estoy tratando de hacer un Applescript que lanza un conjunto diferente de aplicaciones en función de la entrada del usuario. Sin embargo, no se compila. ¿Qué es lo que falla?

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

Lo que debería hacer: Los botones 2 y 3 simplemente lanzan varios conjuntos de aplicaciones, mientras que el botón 1 comprueba si Spotify está en marcha y, si lo está, cambia a él. Si no lo está, abre 3 aplicaciones (incluyendo Spotify).

Sin embargo, al compilar me aparece el error "Expected end of line, etc. but found end of script. Aquí está el script. ¿Qué es lo que falla?

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

0voto

Satanicpuppy Puntos 4902

Te falta 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

AppleAyuda.com

AppleAyuda es una comunidad de usuarios de los productos de Apple en la que puedes resolver tus problemas y dudas.
Puedes consultar las preguntas de otros usuarios, hacer tus propias preguntas o resolver las de los demás.

Powered by:

X