Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AppleScript and non-scriptable applications

Tags:

applescript

I'm wondering how can I script applications which has no dictionary. All information that I've found tells me nothing. But my experience says me that there is a way. For example:

tell application "Firefox"
    return count of windows
end tell

Will work. And it will work with "Opera" and other applications without dictionary at all. So the questions are: 1) Why does it work? 2) What else work in such a manner? Is there a list of all such actions?

Thank in advance!

like image 724
ixSci Avatar asked Jun 28 '26 08:06

ixSci


1 Answers

You can to some extent script applications without an applescript dictionary by using 'tell application "System Events"'

tell application "Keynote" activate 
tell application "System Events" to keystroke "c" using {command down} 
end tell
end tell

This example activates Keynote and then copies the current selection. You can use similar code in many applications even if they don't have an applescript dictionary provided you also have the "Enable access for assistive devices" option checked in the "Universal Access" System Preference.

Edit:

This document gives some details of how Cocoa provides some support for Applscript in all applications: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ScriptableCocoaApplications/SApps_about_apps/SAppsAboutApps.html

Under the heading Built-in Support for Standard and Text Suites

like image 194
Ian Turner Avatar answered Jul 01 '26 14:07

Ian Turner