PDA

View Full Version : Making an Applescript to quit an app




Sharewaredemon
Apr 6, 2006, 08:39 PM
Ok guys, I have ZERO applescript experience.

I recently came upon the megaman effect and I want to make an automator action opens the app, and then quits it.

Opening the app will enable the effect.

There isn't an automator action to quit an application, but I figure applescript could handle that.

Could you guys help me out with that?



Laser47
Apr 6, 2006, 09:15 PM
Quitting an app is very easy with applescript. Take my example of making applescript quit Safari
tell application "Safari"
quit
end tell

Sharewaredemon
Apr 6, 2006, 09:22 PM
Quitting an app is very easy with applescript. Take my example of making applescript quit Safari
tell application "Safari"
quit
end tell


hoora!

thanks a lot, it works!

as it turns out, this app needs to be running in order for it to work. Is there anyway to have an app run without it being visible in the dock?

Laser47
Apr 6, 2006, 09:37 PM
I dont know how to make an app not show in the dock while running.
Also you can reduce the step of automaton opening the app by using this code
tell application "iTunes"
run
end tell

Sharewaredemon
Apr 6, 2006, 09:52 PM
I dont know how to make an app not show in the dock while running.
Also you can reduce the step of automaton opening the app by using this code
tell application "iTunes"
run
end tell

cool, thanks.

Oh well, I guess I might not notice the little megaman icon in the dock when I have this script run to surprise me....

Thanks for your help!

cal81985
Sep 20, 2010, 07:40 PM
You can make an application invisible in the dock by right clicking (ctrl-click) on the application, selecting "Show Package Contents", and opening the Info.plist file within the "Contents" directory. If you don't have the Apple developer tools installed, you will have to do this in TextEdit. I'll assume you don't for this next step.

Once the plist file is opened, look for the "<dict>" tag. Do a search within the document if you have to, but it will almost always look like the following:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>

After you find where the <dict> tag starts, copy and paste this directly underneath:

<key>LSUIElement</key>
<true/>

Save the file and exit. Make sure there are no spaces between the lines to ensure this works!

If you have the developer tools installed, double clicking on the file should automatically open it up with Property List Editor. Once open, click on the dictionary menu ("Information Property List") and select "Add Child" from the toolbar. On the ensuing drop down menu, find "Application is agent (UIElement)" and select that as the key to use. Make sure the check box next to the key is checked, save the plist, and exit.

You can do that with any application. If you have trouble saving the plist file because of permissions issues, just save it as another plist file to your desktop (named Info.plist of course), then simply drag and drop into the "Contents" folder of the application to replace it.