I'm starting to try converting some of my AppleScripts into JavaScript in OS X Yosemite, but I don't understand how I'm supposed to access enums from applications. For example - the status of Adium.
In AppleScript:
tell application "Adium"
if status type of global status is offline then
log "offline"
end if
end tell
In JavaScript I do not know how to access the "offline" enum:
if(Application('Adium').globalStatus.statusType == ?????) {
console.log("offline");
}
I've tried simple things like "offline" without success. All these are errors:
Application('Adium').StatusType("offline"); // error
Application('Adium').StatusType.offline; // undefined
Application('Adium').StatusType.make({name:"offline"}); // error
Anyone gotten something like this working?
While I have been unable to do the enum comparison, I have been able to make this work. In JavaScript for automation, calling just the property returns the ObjectSpecifier for the Apple object. In this case the statusType is a class of "AdiumRichText".
If you put () after the property it calls the getter method which returns a NSString (String) that works fine. So here is the code:
if(Application('Adium').globalStatus().statusType() == "offline") {
console.log("offline");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With