2012-02-17 52 views
2

我需要向一些人發送消息,讓他們知道事件何時發生。它始終是同一個人的列表,並且總是同一個事件,所以我想編寫它。如何使用iChat和AppleScript發送消息

我的問題是我知道我需要用發送命令來發送消息。並且該命令的格式是

tell application iChat to send "message" to _buddy_ 

問題是如何獲得該夥伴。我知道如何讓所有的好友列表,並遍歷它們:

tell application "iChat" 
    repeat with myBuddy in buddies 
    end repeat 
end tell 

似乎我無法找到是如何只得到我在乎的哥們,例如那些有名字「 Pietje Piet「和」Joe Anonymous「,然後只是發送消息給這兩個聯繫人。

回答

4

您必須以某種方式在單獨的列表中獲得您關心的好友列表。這裏有一個建議:

set peopleICareAbout to {"Pietje Piet", "Joe Anonymous"} 

tell application "iChat" 
    repeat with myBuddy in buddies 
     --get properties of myBuddy 
     if full name of myBuddy is in peopleICareAbout then 
      send "dfgdgdf gdg dfg dfg" to myBuddy 
     end if 
    end repeat 
end tell 
+0

這正是我想要的!雖然我不得不改變消息,當然;-) – 2012-02-17 08:55:07

+1

哎呀,糟糕的語義我猜:) – tompaman 2012-02-17 08:56:27

+0

這對OS X Yosemite很好,只需要將應用程序更改爲「消息」。 – 2015-08-14 16:33:53