Dec 10, '03 09:05:00AM • Contributed by: pdm
You can use the System Events feature of OS X to activate any menu options. For this to work, you must have "Enable access for assistive devices" enabled on the Universal Access system preference pane.
Create a new AppleScript program in Script Editor with the following code, and save it as an application:
tell application "Safari" to activate tell application "System Events" tell process "Safari" click menu item "New Window" of menu "File" of menu bar 1 end tell end tellNow, find some spiffy icon to assign to your new application and drag it to the dock. I put this application right above the real Safari application, and assigned it a different icon. When you click on this new program, it will open a new Safari window. One quirk is if Safari isn't already running, it will launch two windows since Safari loads one on startup. I've only tested this on 10.3.