• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Mavericks and UI
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mavericks and UI


  • Subject: Re: Mavericks and UI
  • From: Bill Cheeseman <email@hidden>
  • Date: Thu, 08 May 2014 16:18:25 -0400


On May 8, 2014, at 3:49 PM, email@hidden wrote:

What was confusing my users is that when the script ran and the dialog opened it took them to the accessibility pane, but the setting they need to change is in the security and privacy pane. What a pain. 

Hey Ed!

Here's a universal handler to include in all of your GUI Scripting scripts so they will work in the new Mavericks world and the old world. This is included with the current version of my UI Browser product to help you write GUI Scripting scripts <http://pfiddlesoft.com/uibrowser>.

on enabledGUIScripting(flag)
get system attribute "sysv"
if result is less than 4240 then -- 4240 is OS X 10.9.0 Mavericks


-- In OS X 10.8 Mountain Lion and older, enable GUI Scripting globally by calling this handler and passing 'true' in the flag parameter before your script executes any GUI Scripting commands, or pass 'false' to disable GUI Scripting. Authentication is required only if the value of the 'UI elements enabled' property will be changed. Returns the final setting of 'UI elements enabled' even if unchanged.


tell application "System Events"
activate -- brings System Events authentication dialog to front
set UI elements enabled to flag
return UI elements enabled
end tell
else


-- In OS X 10.9 Mavericks, global access is no longer available and GUI Scripting can only be enabled manually on a per-application basis. Pass true to present an alert with a button to open System Preferences and telling the user to select the current application (the application running the script) in the Accessibility list in the Security & Privacy preference's Privacy pane. Authentication is required to unlock the preference. Returns the current setting of 'UI elements enabled' asynchronously, without waiting for System Preferences to open, and tells the user to run the script again.


tell application "System Events" to set GUIScriptingEnabled to UI elements enabled -- read-only in OS X 10.9 Mavericks
if flag is true then
if not GUIScriptingEnabled then
activate
set scriptRunner to name of current application
display alert "GUI Scripting is not enabled for " & scriptRunner & "." message "Open System Preferences, unlock the Security & Privacy preference, select " & scriptRunner & " in the Privacy Pane's Accessibility list, and then run this script again." buttons {"Open System Preferences", "Cancel"} default button "Cancel"
if button returned of result is "Open System Preferences" then
tell application "System Preferences"
tell pane id "com.apple.preference.security" to reveal anchor "Privacy_Accessibility"
activate
end tell
end if
end if
end if
return GUIScriptingEnabled
end if
end enabledGUIScripting
-- 

Bill Cheeseman - email@hidden



-- 

Bill Cheeseman - email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: Mavericks and UI (From: "email@hidden" <email@hidden>)

  • Prev by Date: Re: Mavericks and UI
  • Next by Date: Re: How to parse a block of text
  • Previous by thread: Re: Mavericks and UI
  • Next by thread: name of the current desktop picture
  • Index(es):
    • Date
    • Thread