how to close an application created with script editor

Discussion in 'Mac Programming' started by bitstomper, Feb 29, 2008.

  1. macrumors newbie

    Joined:
    Feb 29, 2008
    #1
    Hi,

    Simple question:
    I have a script and saved it as an application.
    It runs fine but the app stays open and I have to force quit it before I shut down.
    What is the instruction to actually close the application (itself).

    Thanks

    on run
    do shell script "/Applications/synergy-1.3.2/synergys -f --config /Applications/synergy-1.3.2/synergy.conf "
    end run
     
  2. macrumors 6502a

    lancestraz

    Joined:
    Nov 27, 2005
    Location:
    RI
    #2
    When you save your script from Script Editor, make sure the "Stay Open" checkbox in the "Save as..." sheet is not selected.
     
  3. thread starter macrumors newbie

    Joined:
    Feb 29, 2008
    #3
    thanks but that was not selected so makes no diff.
     
  4. macrumors 6502a

    lancestraz

    Joined:
    Nov 27, 2005
    Location:
    RI
    #4
    Try this:
    Code:
    on run
    	do shell script "/Applications/synergy-1.3.2/synergys -f --config /Applications/synergy-1.3.2/synergy.conf > /dev/null 2>&1 &"
    end run
    I don't have synergy so I can't test this...
     
  5. thread starter macrumors newbie

    Joined:
    Feb 29, 2008
    #5
    you dont need synergy
    I am trying to close down the script application after it was run
     
  6. macrumors 6502

    Joined:
    Jun 16, 2004
    #6
    What lancestraz is trying to say is that most likely synergy hasn't quit, and therefore your application won't quit. Try putting
    Code:
    display dialog "It quit"
    at the end of your script. If it doesn't come up, follow what lancestraz said, if it does then its a different problem.
     
  7. thread starter macrumors newbie

    Joined:
    Feb 29, 2008
    #7
    on compile I get:

    The run handler is specified more than once, or there were top-level commands in addition to the run handler.

    on run
    do shell script "/Applications/synergy-1.3.2/synergys -f --config /Applications/synergy-1.3.2/synergy.conf "
    end run

    display dialog "It quit"


    I do not want synergy to quit.
    The whole point was writing a script that starts up synergy.
    But the script application remains open after running the run command.
    If there is an other way, please let me know.
    btw If I force quite the application synergy remains running (it's a server and client program to use one keyboard and mouse on multiple computers)
     
  8. macrumors 6502a

    lancestraz

    Joined:
    Nov 27, 2005
    Location:
    RI
    #8
    The "display dialog" needs to go inside the run block.
    What is probable happing is when you do the shell script "/Applications/synergy-1.3.2/synergys -f --config /Applications/synergy-1.3.2/synergy.conf" it will infinitely sit there wondering what to do with it's output. If you tack on "> /dev/null 2>&1 &" to the end of the shell script (still inside the quotes) the AppleScript should quit.
    So your script should look like this:
    Code:
    on run
    	do shell script "/Applications/synergy-1.3.2/synergys -f --config /Applications/synergy-1.3.2/synergy.conf > /dev/null 2>&1 &"
    display dialog "I'm quitting."
    end run
    If you get the "I'm quitting" dialog when you run the script, everything is working OK and you can remove that line from the script. If you get it and click "OK" and the script still doesn't quit, I have one more idea....
     

Share This Page