Applescript: Can I find the account being used in a window?

An instant messenger which can connect to AIM, GTalk, Jabber, ICQ, and more.
Post Reply
aperantos
Harmless
Posts: 18
Joined: Tue Feb 08, 2005 1:31 am
Location: London, UK

Applescript: Can I find the account being used in a window?

Post by aperantos »

I hope this is an okay place to ask this.

I want to access the messaging account being used by the front most chat window. Looking the the dictionary I should be able access the contact who I am talking to, but I cannot see anything to suggest a way to find out which of my accounts I am using. Is this impossible?

Michael.
User avatar
evands
Cocoaforge Admin
Posts: 3152
Joined: Thu Dec 02, 2004 10:55 pm
Location: Decatur, GA
Contact:

Post by evands »

From the contact, can't you access its account?
The duck still burns.
--
My company: Saltatory Software. Check it out :)
User avatar
twopeak
Crema
Posts: 407
Joined: Tue Jan 25, 2005 2:53 pm
Location: Flanders - Belgium

Post by twopeak »

I think aperantos wants to send an IM to a contact through Applescript.
Some people (like me) have one contact listed in several accounts.
It seems like it's not possible to decide from what account you will start messaging the contact when using applescript.
Image
aperantos
Harmless
Posts: 18
Joined: Tue Feb 08, 2005 1:31 am
Location: London, UK

Post by aperantos »

Sorry, I will try to be clearer.

Basically I want to find out "who am I?". For example, I start a chat with my "aperantos_uk" username talking to "somebody_else". Obviously I know who I am, but a script does not and I want it to detect that I am "aperantos_uk".

The dictionary for "interface Controller" has an "active chat" property that provides:

"contact contact [r/o] -- The contact with which this chat is taking place. If the chat is with multiple contacts, this will be NULL."

So this will be a contact class object for "somebody_else" but I want to access the contact class object for "aperantos_uk" and I cannot see anything equivalent.

That said, it might just be me, but I cannot even get the active chat. 'Telling' Adium to "set myChat to the active chat of the interface controller" returns nothing, though it could be that it is being clever and can tell I am chatting to myself. I can get the interface controller without any problems though.

Michael.
User avatar
evands
Cocoaforge Admin
Posts: 3152
Joined: Thu Dec 02, 2004 10:55 pm
Location: Decatur, GA
Contact:

Post by evands »

Gotcha.

Added an account property to chat objects for 0.8b9. Will investigate the active chat problem... could you please post a sample script which would make use of active chat but which shows it not working properly?
The duck still burns.
--
My company: Saltatory Software. Check it out :)
aperantos
Harmless
Posts: 18
Joined: Tue Feb 08, 2005 1:31 am
Location: London, UK

Post by aperantos »

The account property would be wonderful, thank you.

What I am trying to do is create a "/nick" script as mentioned on another thread. Although I could include the IM account username as a parameter, to change a current display name from within a chat window it should not be needed.

As a test script I have tried:

Code: Select all

tell application "Adium"
	set myChat to the active chat of the interface controller
	set myContact to the contact of myChat
	set display name of myContact to "Test New Name"
end tell
Which I would expect to set the alias of the person I am chatting to. But when I run this as an .adiumscript (within .8b8) it crashes, and within the Script Editor I get a "Can't get active chat of interface controller." even though I do have an active chat window open.

Michael.
User avatar
evands
Cocoaforge Admin
Posts: 3152
Joined: Thu Dec 02, 2004 10:55 pm
Location: Decatur, GA
Contact:

Post by evands »

Associated email for that crash log?
The duck still burns.
--
My company: Saltatory Software. Check it out :)
aperantos
Harmless
Posts: 18
Joined: Tue Feb 08, 2005 1:31 am
Location: London, UK

Post by aperantos »

Associated address is michael(at)aperantos.com

Having just looked in my trash, I can only find an Adium.exception.log which simply says:
OS Version: Version 10.2.8 (Build 6R73)
Exception: NSInvalidArgumentException
Reason: *** -[NSCFString executeSubroutineNamed:argumentsArray:]: selector not recognized
Stack trace:
Michael.
User avatar
zaudragon
Growl Team
Posts: 1852
Joined: Sat Dec 04, 2004 5:05 am
Location: Kensington, CA, USA
Contact:

Post by zaudragon »

The log should be ~/Library/Logs/CrashReporter/Adium.crash.log
Blog | X(tras)
Communists code without classes.
User avatar
evands
Cocoaforge Admin
Posts: 3152
Joined: Thu Dec 02, 2004 10:55 pm
Location: Decatur, GA
Contact:

Post by evands »

*cringes at seeing a crash in 10.2.8 he's never seen in 10.3.x*
The duck still burns.
--
My company: Saltatory Software. Check it out :)
aperantos
Harmless
Posts: 18
Joined: Tue Feb 08, 2005 1:31 am
Location: London, UK

Post by aperantos »

This is really a beta issue now but I thought it better to stick to the same thread so maybe it should be moved?

I have tried again with .8b10 but the crashes still exist.

This is my test script which I have installed as an adiumScript:

on substitute(theNewName)
tell application "Adium"
return long display name of the account of the active chat of the interface controller
end tell
end substitute

Running this caused the crash.

If I try to run the script (without the "on substitute" of course) in the AppleScript Editor I get a dialogue "Can't get active chat of the interface controller".

If I try a script of:

tell application "Adium"
get every interface controller
return result
end tell

I get told "the variable result is not defined" so I think the problem is in accessing the interface controller itself.

The adium.exception.log file in the trash is identical to the above, and all I have in the location zaudragon specifies is an "Adium Crash Reporter.crash.log".

I have submitted a crash report under the name michael (at) aperantos.com and also included all of the above detail. I am just posting on here in case anyone else is interested in seeing if it produces the same effect.

Give me a month though and I will move onto Tiger so all these Jaguar problems will be behind me!

Michael.
csolallo
Harmless
Posts: 1
Joined: Mon Sep 12, 2005 4:57 am
Contact:

Post by csolallo »

Hi,

I don't think this has to do with the beta... I'm seeing a similar behavior in the latest release (0.86).

If I type the following script

tell application "Adium"
set myChat to the active chat of the interface controller
end tell

I see nothing in the script editor's result. That's because the interface controller seems to be returning a reference. The following works:

tell application "Adium"
activate -- this is key!
set myChat to (a reference to the active chat of interface controller 1)
end tell

now myChat will show in the results window and will be of the correct type.

Carlos
Post Reply