PDA

View Full Version : GUI Programming: Adium won't cooperate




interairproxima
Nov 29, 2010, 07:11 PM
Hey guys,
This is my first time trying to even delve into the world of programming, so excuse my lack of knowledge. I've been trying to get my Adium Status and push it to be my Twitter "status" (actually the next tweet). No programs out there do anything of the sort, so I tried to use a template GUI script to automate the process of going to Status->Twitter Account->Set to Current Adium Status. This is the code I was trying to use:

tell application "Adium"
activate
end tell
tell application "System Events"
tell process "Adium"
tell menu bar 1
tell menu bar item "Status"
tell menu "Account Name"
click menu item "Set to Current Adium Status"
end tell
end tell
end tell
end tell
end tell
return true

It keeps telling me it can't find that menu option under Status. Am I missing something obvious? The actual path of clicks should be Adium->Status->Twitter Account->Set to Current Adium Status.

Thanks in advance!



dethbunny
Nov 30, 2010, 01:41 PM
When you deal with a sub-menu, you have to tell the "item" that represents it, then tell the sub-menu that pops up. It looks a little weird and results in some things looking like they're being duplicated.

tell application "Adium"
activate
end tell
tell application "System Events"
tell process "Adium"
tell menu bar 1
tell menu bar item "Status"
tell menu "Status"
tell menu item "Twitter Account"
tell menu "Twitter Account"
click menu item "Set to Current Adium Status"
end tell
end tell
end tell
end tell
end tell
end tell
end tell

interairproxima
Nov 30, 2010, 03:41 PM
Hey dethbunny,
I tried the script, but the Script Editor spits out that it can't find the Twitter Account menu item; it also can't find my google account or my aim account (i'm using my username to find them). Oddly enough, I think it locates my facebook account fine. The Set to Current Adium Status works with the script.
What am I missing?

dethbunny
Nov 30, 2010, 05:39 PM
You have to use the actual name of the account used. For example, say you have an AIM account with the screen name "interairproxima."

Your code would then include something like this:
tell application "Adium"
activate
end tell
tell application "System Events"
tell process "Adium"
tell menu bar 1
tell menu bar item "Status"
tell menu "Status"
tell menu item "interairproxima"
tell menu "interairproxima"
click menu item "Available"
end tell
end tell
end tell
end tell
end tell
end tell
end tell

This works for me, assuming i use my own account name. If you have multiple accounts with the same name, though, you'll have trouble - perhaps something that uses "tell menu item 12" instead of "tell menu 'username'" would work better in that situation.

interairproxima
Nov 30, 2010, 07:21 PM
GOT IT! It only took 20 minutes of trying to find out which menu item number my twitter account was (ended up being 18), but I believe I got it.
Except now I need a way to run that script right after I change my adium status...Any suggestions?
Right now I have it set so that if I send off a message the script runs, which probably isn't ideal.
Thanks for all the help!