Applescript help requested

xstatical

Registered
Can someone with Applescript knowledge please tell me why this script does not work and suggest a fix. I copied it from part of a longer script I found on the internet to enable private browsing automatically when Safari is launched. After it launches Safari, the script crashes before private browsing is enabled so I assume the error occurs at that step.

-- Sets Private Browsing
-- Also automatically dismisses the pop-up information window
on run {}
activate application "Safari"
tell application "System Events" to tell application process "Safari"
click menu item "Private Browsing" of menu 1 of menu bar item "Safari" of menu bar 1
click button "OK" of window 1
end tell
end run
 
Open this Scriplet in your Editor:

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.
 
Sorry to be inquisitive but what does "Enable access for assistive devices" do that makes the script work? Your script works like a charm but I still can't get it to click the ok button to close the pop-up window in the script. Any suggestions?
 
"Enable access for assistive devices" is required to enable "GUI scripting", which lets you manipulate interface elements like buttons through AppleScript. You might still need to enable GUI scripting, which can be done in AppleScript Utility, located in /Applications/AppleScript.
 
Back
Top