PDA

View Full Version : how to close an application created with script editor




bitstomper
Feb 29, 2008, 09:25 PM
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



lancestraz
Feb 29, 2008, 09:29 PM
When you save your script from Script Editor, make sure the "Stay Open" checkbox in the "Save as..." sheet is not selected.

bitstomper
Feb 29, 2008, 09:39 PM
thanks but that was not selected so makes no diff.

lancestraz
Feb 29, 2008, 09:51 PM
Try this:
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...

bitstomper
Feb 29, 2008, 10:01 PM
you dont need synergy
I am trying to close down the script application after it was run

sord
Mar 1, 2008, 12:39 AM
What lancestraz is trying to say is that most likely synergy hasn't quit, and therefore your application won't quit. Try putting 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.

bitstomper
Mar 1, 2008, 01:23 AM
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)

lancestraz
Mar 1, 2008, 08:38 AM
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)
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:
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....