Hi Forest_Lin,
I am going to leave you in Barney's hands as he has a better understanding of AppleScript than I do.
Your latest Script though, takes ideas for the iChat "side" of Messages and tries to apply them to the iMessages account from what I can see.
Messages can have 5 account types.
In order that they have been added to the App
Bonjour (was Rendezvous in early versions). This account is always there even if not active
AIM - the original External Service that iChat 1 could do.
Jabber - added a t iChat 3
Yahoo - Added at iChat 6
iMessages added at Mountain Lion.
Bonjour has a Buddy list but cannot add Buddies.
The Buddies are the Users on other Macs on your LAN that have the Bonjour account Active in their Messages or iChat and it pulls their Address Card (My Card) and "broadcasts" this as their Buddy Name.
AIM, Jabber (plus their variants) and Yahoo also have Buddy lists that you can add Buddies to.
The iMessages Account uses the names in your Contact App when a Phone Number or email is listed (there are then checks to see if that is an iMessages registered ID).
There is no Buddy list.
I can't see from the current Dictionary for Messages that much has been added to facilitate the inclusion of iMessages.
However in the Interface (Messages) window you can type an Apple ID or iPhone number directly into the "To" spot and then use the items as a Drop down to select the "From" to make it an iMessages conversation.
(You can SMS to certain U.S. Phones using an AIM account this way)
As Barney says, the interface may be simpler.
7:13 PM Saturday; July 6, 2013
iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.4)
G4/1GhzDual MDD (Leopard 10.5.8)
MacBookPro 2Gb (Snow Leopard 10.6.8)
Mac OS X (10.6.8),
Couple of iPhones and an iPad
"Limit the Logs to the Bits above Binary Images." No, Seriously
Message was edited by: Ralph Johns (UK)