GUIScriptingChecker Reference

GUIScriptingChecker is an AppleScript library to check availability of “GUI Scripting”.Also if “GUI Scripting” is not enabled, GUIScriptingChecker can guide a user to enable “GUI Scripting” with displaying proper messages.

The default status of “GUI Scripting” is OFF.Therefore availability of “GUI Scripting” should be confirmed at the beginning of the script and a proper guide should be provided if needed.

The GUIScriptingChecker can help to perform such boring routine task with minimum efforts.

In OS X 10.9 or later, the following dialog will be displayed when “GUI Scripting” is OFF.

By clicking “Open System Preferences” button, the Accessibility section in the Security & Privacy preference pane in System Preferences will be opend.Your script can not continue to work, because “GUI Scripting” can't be enabled by a script.

In OS X 10.8 or before, the following dialog will be displayed.

If a user pushes “Enable GUI Scripting” button, “GUIScriptingChcker” try to enable “GUI Scripting”.If “GUI Scripting” is enabled through authorization process, the script can contiue to work.

Basic Usage

use scripting additions
use GUIScriptingChecker : script "GUIScriptingChecker"

if not GUIScriptingChecker's do() then
return
end if

-- Scripts dpended on GUI Scripting --

display alert "GUI Scripting is enabled."

Localizing Messages

Messages are displayed when “GUI Scripting” is OFF can be localized by giving a delegate to "GUIScriptingChecker" as follows.

use scripting additions
use GUIScriptingChecker : script "GUIScriptingChecker"

script JapaneseLocalizer
on ok_button()
return "システム環境設定を開く"
end ok_button

on cancel_button()
return "拒否"
end cancel_button

on title_message()
return quoted form of (get name of current application) & " は、アクセッシビリティ機能を使用してこのコンピュータの制御することを求めています。"
end title_message

on detail_message()
return "システム環境設定の「セキュリティーとプライバシー」環境設定で、このアプリケーションへのアクセスを許可してください。"
end detail_message
end script

tell GUIScriptingChecker's set_delegate(JapaneseLocalizer)
if not do() then return
end tell

-- Scripts dpended on GUI Scripting --

display alert "GUI Scripting is enabled."

Basic Methods

make

Make a copy of an instance of GUIScriptingChcker

do

Check availability of “GUI Scripting”

set_delegate

set a delegate script

localize_messages

Obtain message texts from "Localizable.strings" in the resource folder in the current bundle.

Delegate Methods

A delegate script is used for localizing messages in a dialog shown when GUI Scripting is disabled.

ok_button

Return a label text for “OK” button.

cancel_button

Return a label text for “Cancel” button.

title_message

Return a title text for a dialog.

detail_message

Return a detail message for a dialog.