OSX Yosemite - JavaScript for Automation - Accessing Adium E

An instant messenger which can connect to AIM, GTalk, Jabber, ICQ, and more.
chanomie
Harmless
Posts: 2
Joined: Mon Aug 11, 2014 5:07 am

OSX Yosemite - JavaScript for Automation - Accessing Adium E

Postby chanomie » Mon Aug 11, 2014 5:13 am

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?

chanomie
Harmless
Posts: 2
Joined: Mon Aug 11, 2014 5:07 am

Re: OSX Yosemite - JavaScript for Automation - Accessing Adi

Postby chanomie » Mon Aug 11, 2014 6:21 pm

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");
}


Return to “Adium”

Who is online

Users browsing this forum: Majestic-12 [Bot]