I'm having troubles creating an applescript to open a chat window to a specific person.
I'm trying to write a small script that I can pass a display name or email and it will open a chat window to that person and make it active. I don't care if it makes a new window or not. I'd like it to be account inspecific if possible.
Here's my current code (feel free to recommend completely new code though, this is my first applescript attempt).
tell application "Adium"
if exists contact "contact@gmail.com" or exists contact whose display name is "contact@gmail.com" then
set mycontact = contact "contact@gmail.com" or contact whose display name is "contact@gmail.com" (this errors out here)
tell account of mycontact to set chatWindow to make new chat with contacts {mycontact} with new chat window
activate chatWindow
end if
end tell
I'd also like it to just activate the chat window of the person if it already exists.
Using Applescript (or anything) to open a chat window
Re: Using Applescript (or anything) to open a chat window
I've gotten better, but not perfect code. Here's my code:
The Problems:
1) If I have an open chat window, and i run this, the contact doesn't open in the chat window, even though i have the code "without new chat window"
2) The else tell ... to activate at the end doesn't tell the window with that contact to activate it just tells the front most window to activate
3) How do I tell the window with my contact to activate and to set my contact to the active user?
Any one? Or is this the wrong forum?
Code: Select all
tell application "Adium"
if exists contact "contact@gmail.com" then
set mycontact to contact "contact@gmail.com"
if not (exists (chats whose contacts contains mycontact)) then
set the_window to get every chat window
if the_window = {} then -- now chat window exists
tell account of mycontact to (make new chat with contacts {mycontact} with new chat window)
else -- chat window already exists, make new tab
tell account of mycontact to (make new chat with contacts {mycontact} without new chat window)
end if
activate
else
tell (windows of chats whose contacts contains mycontact) to activate
end if
end if
end tell
1) If I have an open chat window, and i run this, the contact doesn't open in the chat window, even though i have the code "without new chat window"
2) The else tell ... to activate at the end doesn't tell the window with that contact to activate it just tells the front most window to activate
3) How do I tell the window with my contact to activate and to set my contact to the active user?
Any one? Or is this the wrong forum?
Re: Using Applescript (or anything) to open a chat window
It's the correct forum, but not many people actually play around with this stuff.
If the without new chat window fails to work you should file a trac.
I don't think there is a way to set the active chat using applescript without utilizing some of the accessibility scripting stuff. In other words you have to tell system events to click on the button of the tab that you want active in the window.
http://www.macosxautomation.com/applesc ... index.html
If the without new chat window fails to work you should file a trac.
I don't think there is a way to set the active chat using applescript without utilizing some of the accessibility scripting stuff. In other words you have to tell system events to click on the button of the tab that you want active in the window.
http://www.macosxautomation.com/applesc ... index.html