Applescript

Some Applescript I wrote to do windowing and other things. I generally use Quicksilver to activate them.

Maximize

Better maximization than the zoom button: maximizes by moving window to top-left corner of screen and setting the size. Hardcoded for 1024×768. Click here to get it.

tell application "System Events"
  if UI elements enabled then
    set FrontApplication to (get name of every process whose frontmost
		is true) as string
    tell process FrontApplication
      get the position of window 1
      get the size of window 1
      if the position of window 1 is {0, 22} and the size of window 1 is
	  		{1024, 742} then
        click button 2 of window 1
      else
        set position of window 1 to {0, 22}
        set size of window 1 to {1024, 742}
      end if
    end tell
  else
    tell application "System Preferences"
      activate
      set current pane to pane "com.apple.preference.universalaccess"
      display dialog "UI element scripting is not enabled. Check
	  	'Enable access for assistive devices'"
    end tell
  end if
end tell

Maximize Vertically

Just like the above Maximize, but only does it vertically. Useful for terminal windows. Click here to snag it.

Run Terminal

Runs a terminal. Slightly tricky to avoid opening two terminals if Terminal isn't running already. Click here to grab it.

tell application "Finder"
	if "Terminal" is not in the name of every process then
		tell application "Terminal" to activate
	else
		tell application "Terminal"
			activate
			do script ""
		end tell
	end if
end tell
people/dan/applescript.txt · Last modified: 2007/07/03 09:52 (external edit)
chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0