2012-02-17 53 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