Mac Tips

You close a tab accidentally and want to reopen it:



Keyboard shortcut for maximizing current window (or restoring it):
(See http://www.macosxhints.com/article.php?story=20051227001809626 for the originating article.)
Paste the following into a new script and save it thusly:
/Library/Scripts/Maximize.scpt
(Where "Maximize.scpt" is the name you give 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
click button 2 of window 1
--button 2 is the green "zoom" button for all applications
--window 1 is always the frontmost window.
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

Then open your favourite automator (I use iKey) and create a keyboard shortcut to that script. Ta daaa!!



Copy a path for pasting


You know how I wrote out "/Library/Scripts/Maximize.scpt" above? That's the path I mean. If you're in finder, and want to copy the path to a file, check out this script...
http://www.macworld.com/article/133299/2008/05/pathcopy.html

The code:
tell application "Finder"
set sel to the selection as text
set the clipboard to POSIX path of sel
end tell