Making an Applescript to quit an app

Discussion in 'Design and Graphics' started by Sharewaredemon, Apr 6, 2006.

  1. macrumors 68000

    Sharewaredemon

    #1
    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?
     
  2. macrumors 6502a

    Laser47

    #2
    Quitting an app is very easy with applescript. Take my example of making applescript quit Safari
    Code:
    tell application "Safari"
    	quit
    end tell
     
  3. macrumors 68000

    Sharewaredemon

    #3

    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?
     
  4. macrumors 6502a

    Laser47

    #4
    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
    Code:
    tell application "iTunes"
    	run
    end tell
     
  5. macrumors 68000

    Sharewaredemon

    #5
    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!
     
  6. macrumors newbie

    #6
    I know this is like 4 years too late, but...

    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.
     

Share This Page