Page 1 of 1

OSX Yosemite - JavaScript for Automation - Accessing Adium E

Posted: Mon Aug 11, 2014 5:13 am
by chanomie
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 Adium enums.

In AppleScript:

Code: Select all

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:

Code: Select all

if(Application('Adium').globalStatus.statusType == ?????) {
    console.log("offline");
}


I've tried simple things like "offline" without success. All these are errors:

Code: Select all

Application('Adium').StatusType("offline"); // error
Application('Adium').StatusType.offline;     // undefined
Application('Adium').StatusType.make({name:"offline"}); // error


Anyone know how to get this working?

Re: OSX Yosemite - JavaScript for Automation - Accessing Adi

Posted: Mon Aug 11, 2014 6:21 pm
by chanomie
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:

Code: Select all

if(Application('Adium').globalStatus().statusType() == "offline") {
    console.log("offline");
}