我正在尝试为Automator编写一个AppleScript应用程序来操作联系人组。我收到一个联系人项目作为脚本的输入,但我坚持如何解析它。这是我到目前为止写的来源:
script Labels_for_contact_groups
property parent : class "AMBundleAction"
on runWithInput_fromAction_error_(input, anAction, errorRef)
-- Get parameters
set labelName to valueForKey_("trainingLabelName") of parameters() of me
set labelValue to valueForKey_("trainingLabelValue") of parameters() of me
-- Iterate over the contact groups
-- what should I do here?
log input
return input
end runWithInput_fromAction_error_
end script
我在日志中得到以下内容:
2016-10-12 11:35:28.061 Automator[2167:174553] <NSAppleEventDescriptor: [ 'obj '{ 'want':'azf5', 'form':'ID ', 'seld':'utxt'("50E8C441-3DF0-4CD7-8E36-E175B37D2CCB:ABGroup"), 'from':[0x0,10d10d "Contacts"] } ]>
我需要做的是提取指定组中所有联系人的信息。我该怎么办?
编辑: 我添加了以下行
tell application "Contacts" to set thePeople to people of input
repeat with i from 1 to number of items in thePeople
set thisPersonCurrent to item i of thePeople
log thisPersonCurrent
end repeat
现在我收到以下错误:
[Labels_for_contact_groups runWithInput:fromAction:error:]: Can’t get every «class azf4» of «class ocid» id «data optr0000000080A9220080600000». (error -1728)
我做错了什么?
答案 0 :(得分:0)
我想要实现的目标并不适用于Automator。我意识到API中存在许多空白。最终工作的是一个独立的AppleScript,其中包含以下行:
tell application "Contacts"
set theGroupNames to name of groups
set text_returnedCurrent to choose from list theGroupNames with prompt "Select Group" without multiple selections allowed
set the_peopleCurrent to people of group (text_returnedCurrent as text)
...