[请注意:该网站不允许我发布此问题,除非我错误地设置了格式,即“代码”的两个中间部分,它们实际上并不是代码。我已尽力进行编辑,修复,如果格式不正确,我深表歉意。
我已经找到并调整了两个脚本,它们分别运行。这是我的第一个AppleScript项目,我希望获得帮助[[将它们加入一起进行脚本编写。
我希望脚本2使用脚本1的结果。
例如将菜单项设置为(脚本1结果名称)我在通讯录中做了一个虚拟的testGroup。弹出菜单仅需要名称。稍后,我将在另一个脚本中使用相应的电子邮件地址。我希望这足够清楚。预先感谢您的帮助。
脚本1
--returns Contacts testGroup’s names and email addresses
set myList to ""
tell application "Contacts" to repeat with p in people in group "testGroup"
if emails of p is {} then
set e to ""
else
set e to value of email 1 of p
end if
set myList to myList & name of p
end repeat
脚本1结果需要解析...
"Joe BloggsMolly MousePeter Pan"
到此...
{"Joe Bloggs", "Molly Mouse", "Peter Pan"}
所以我可以在下面的脚本2 menuItem中使用它。必须使用脚本1结果中的名称,像这样[脚本2
-- Make Pop-Up Menu in Numbers spreadsheet which is already open.
set menuItems to {"Joe Bloggs", "Molly Mouse", "Peter Pan"}
tell application "Numbers"
activate
tell the first table of the active sheet of document 1
tell cell "A3"
set value to item 1 of menuItems
set the format to pop up menu
end tell
end tell
end tell
tell application "System Events"
tell application process "Numbers"
set frontmost to true
tell window 1
click radio button "Cell" of radio group 1
repeat with i from 2 to (count menuItems)
click button 1 of group 1 of scroll area -1
keystroke (item i of menuItems)
end repeat
end tell
end tell
end tell
menuItems
可以通过以下方式设置:tell application "Contacts" to set menuItems to the name of people in group "testGroup"