Hi,
Looking at this document : Javascript for Automation, you can now write Javascript code instead of AppleSript to automate things on your Mac. As far as I understand, it’s a matter of language bindings on underlying framework, and it should be transparent to applications. (If I’m wrong, correct me !)
I’m trying to rewrite this small (working) AppleScript code :
tell application "OmniOutliner"
tell document 1
set width of column 3 to 123
end tell
end tell
The equivalent Javascript might be :
Application('OmniOutliner').document[0].column[2].width=123;
But it fails with error :
Error -1700: Can't convert types.
I tried with document[1].column[3]
in case of fancy 1 based indexes, but of course, this is not the problem.
It should be noted that the following code :
console.log("width.set : "+app.document[0].column[2].width.set)
produces this output (and no error) :
/* width.set : function () {
[native code]
} */
loosely suggesting that we might be close to have some setter being called (and showing at least that the app.document[0].column[2]
stuff is understood, in some way).
I thought that turning off restrictive “strict” stuff such as :
app.strictPropertyScope = false;
app.strictCommandScope = false;
app.strictParameterType = false;
might help, but it doesn’t.
Do you have any ideas why it’s not working, and how it could/should be done ? Does anyone had any success trying to use Javascript instead of AppleScript with Omni apps ?
Best wishes,
Julien
(Running OS X 10.10 and OO 4.1.4)