I’m trying to write a script that will launch Safari and then automatically enable Private Browsing. Could anyone possibly help me figure out whats wrong with this?
tell application "Safari"
tell menu bar 1
click menu item "Private Browsing" of menu "Safari"
end tell
end tell
Any suggestions that anyone may have would be greatly appreciated!
GUI scripting is handled by the application “System Events”, not the individual applications (if the applications supported scripting, you wouldn’t need GUI scripting in the first place!). Try this:
tell application "Safari" to activate
tell application "System Events"
tell process "Safari" to click menu item "Private Browsing" of menu "Safari" of menu bar 1
end tell
Make sure “Enable access for assistive devices” is checked in the Universal Acces pref pane of System Preferences.
Jon
Model: PowerBook 1.25MHz
AppleScript: 1.10
Browser: Safari 412
Operating System: Mac OS X (10.4)