PS I think I have posted this kind of code before, but FWIW you can inspect the methods of the JS Automation object by running something like:
(function () {
'use strict';
var lstSeen = ['Automation'];
var keyTree = function keyTree(o, strIndent) {
var indent = strIndent || '',
ks = Object.getOwnPropertyNames(o)
.filter(function (k) {
return ['name', 'prototype', '__private__'].indexOf(k) === -1 &&
lstSeen.indexOf(k) === -1 ? (lstSeen.push(k), true) : false;
})
.sort();
return ks.length ? ks.map(function (k) {
return indent + k + '\n' + keyTree(o[k], indent + ' ');
})
.join('') : '';
};
return 'Automation\n' + keyTree(Automation, ' ');
})();
Automation
Application
currentApplication
Library
ObjC
$
Ref
equals
bindFunction
block
castObjectToRef
castRefToObject
deepUnwrap
dict
import
interactWithUser
registerSubclass
super
unwrap
wrap
ObjectSpecifier
Path
Progress
delay
getDisplayString
initializeGlobalObject
log
and if you look at Object.getOwnPropertyNames() above, it may suggest ways of testing an object at runtime by seeing whether or not it has a particular method or property.
The full range of tools at your disposal can be listed with:
(function() {
'use strict';
return Object.getOwnPropertyNames(Object);
})();
which yields:
[
"getPrototypeOf",
"setPrototypeOf",
"getOwnPropertyDescriptor",
"getOwnPropertyDescriptors",
"getOwnPropertyNames",
"getOwnPropertySymbols",
"keys",
"defineProperty",
"defineProperties",
"create",
"seal",
"freeze",
"preventExtensions",
"isSealed",
"isFrozen",
"isExtensible",
"is",
"assign",
"name",
"prototype",
"length"
]