Page 1 of 1
Applescript: Can I find the account being used in a window?
Posted: Tue Apr 05, 2005 10:23 pm
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.
Posted: Wed Apr 06, 2005 2:41 am
by evands
From the contact, can't you access its account?
Posted: Wed Apr 06, 2005 9:21 am
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.
Posted: Wed Apr 06, 2005 1:08 pm
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.
Posted: Wed Apr 06, 2005 4:27 pm
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?
Posted: Wed Apr 06, 2005 10:00 pm
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.
Posted: Wed Apr 06, 2005 10:14 pm
by evands
Associated email for that crash log?
Posted: Thu Apr 07, 2005 10:11 am
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.
Posted: Thu Apr 07, 2005 5:39 pm
by zaudragon
The log should be ~/Library/Logs/CrashReporter/Adium.crash.log
Posted: Thu Apr 07, 2005 8:07 pm
by evands
*cringes at seeing a crash in 10.2.8 he's never seen in 10.3.x*
Posted: Wed Apr 20, 2005 3:19 pm
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.
Posted: Tue Dec 13, 2005 8:16 pm
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