Applescript to make terminal close automatically?

Discussion in 'Mac Programming' started by Ri-dog, Jan 17, 2013.

  1. Ri-dog, Jan 17, 2013
    Last edited: Jan 17, 2013

    macrumors newbie

    Joined:
    Jan 17, 2013
    Location:
    Healy, AK
    #1
    Hi,

    I have a relitivly simple question about doing a simple task with applescript.

    I want to automate changing the "when the shell exits" menu in terminal (Preferences > Settings Tab > Shell). From "Don't close the window" to "Close the window".

    [​IMG]

    How would I go about doing this?

    Thank's for the help!

    - Ridog
     
  2. macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    You can try UI scripting.

    Code:
    -- Note : added delays so you can see what the script does
    -- You can remove the delays
    activate application "Terminal"
    tell application "System Events"
    	tell process "Terminal"
    		-- insert GUI Scripting statements here
    		click menu item "Preferences…" of menu 1 of menu bar item "Terminal" of menu bar 1
    		delay 2
    		click radio button 3 of tab group 1 of group 1 of window "Settings"
    		delay 2
    		click pop up button 1 of tab group 1 of group 1 of window "Settings"
    		delay 2
    		click menu item 1 of menu 1 of pop up button 1 of tab group 1 of group 1 of window "Settings"
    		-- If you want to close the "Settings window"
    		-- uncomment the next 2 lines
    		-- delay 2
    		-- click button 1 of window "Settings"
    	end tell
    end tell
    
    Note : It will act on your default setting. Tested on Leopard. YMMV
     

Share This Page