FrontAccess Reference

FrontAccess is an AppleScript module to obtain information for application process and its frontmost document using GUI Scripting. FrontAccess can help building a script which does not depend on a certain application.The features of FrontAccess are..

Enable GUI Scripting

FrontAccess requires GUI Scripting.

To enable GUI Scripting, the application using FrontAcess must be registerd in the Accessibility section in the Security & Privacy preference pane in System Preferences.

GUIScriptingChercker is useful to check availability of GUI Scripting.

Examples

use FrontAccess : script "FrontAccess"
use GUIScriptingChecker : script "GUIScriptingChecker"

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

tell (make FrontAccess) -- Making an instance of FrontAccess
(* Obtain application name and file alias *)
log application_name()
log application_alias()

(* Obtain the file alias of the front document *)
log document_alias()
end tell

Constructor Methods

make

Make an instance of FrontAccess for the frontmost application.

make_for_app

Make an instance of FrontAccess for the specified application

make_for_appfile

Make an instance of FrontAccess for the application specified by a file reference.

Obtain application information

application_name

Obtain the application name.

bundle_identifier

Obtain the application's bundle identifier.

application_info

Obtain information for the application file.

application_alias

Obtain an alias to the application file.

application_process

Obtain a reference to the application process.

is_current_application

Whether a target instance indicates current application.

Obtain document information

document_window

Obtain a reference of the frontmost window of the application. The window is related with a file.

main_window

Obtain a reference of the frontmost window of the application. The window is not always related with a file.

document_url

Obtain a file URL of the frontmost document of the application

document_alias

Obtain an alias to the file of the frontmost document of the application

Saving and Closing the Document

save_document

Perform saving the frontmost document of the application.

close_document

Perform closing the frontmost document of the application.

set_keytype_emulation

When true is passed, key-type emulation ("Command + w") is used for close_document.

paste_text

Put a text into the clipboard and emulate typing Command+v.