macos - 在 Applescript 中显示联系人

标签 macos applescript contacts

我想知道如何在 Applescript 中显示联系人。基本上,我需要打开“联系人”,然后打开我想要的联系人。我不知道联系人的语法。

基本上,我所拥有的就是

tell application "Contacts"
activate
end tell

所以,是的。基本上没什么哈哈。我也尝试过:

tell application "Contacts"
set theContact to "Jason Wells"
open person theContact
end tell

但是,这不起作用。

感谢任何帮助。

谢谢。

最佳答案

联系人有点奇怪,至少就我而言,似乎有点错误。

如果“通讯录”打开,则会显示其窗口;如果关闭窗口,它就会关闭应用程序。这意味着只要你选择你想要的人,那个人就会显示出来。

所以这应该能让你继续:

--AppleScript seems to need Address Book as the application name
--it will rename it to Contacts on save or compile.
tell application "Address Book"
    activate
    set theContact to the first person whose name is "Jerold Stratton"
    --first group appears to be "card".
    set theGroup to second item of groups of theContact

    --first, move to a group that contains this contact
    set selected of theGroup to true

    --second, select the contact
    set selection to theContact
end tell

现在,就我而言,存在一个错误:应用程序名为“联系人”,但 AppleScript 找不到名为“联系人”的应用程序。它会发现它名为“地址簿”。然后,它会将其重命名为“联系人”,这意味着下次您在“联系人”关闭时编辑脚本时,它将无法找到该应用程序或其术语,直到您将其从“联系人”编辑回“地址簿”为止。这是在 OS X 10.9.4 上。

关于macos - 在 Applescript 中显示联系人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25496791/

相关文章:

javascript - AppleScript - 在 Opera 上执行 JavaScript

contacts - Windows Phone 8 自定义联系人存储和扩展属性

java - 有什么方法可以获取联系人应用程序的图标?

css - @fontface Quicksand Light 适用于 Mac/iPhone/iPad

macos - Visual Studio for Mac 2017 RC 上的 ASP.NET Web API 2

macos - 使用 Swift 获取我的 MacBook 的电池状态

java - 直接在 Java 中获取 Finder 选择,无需任何 Applescript 的帮助

shell - 不能用 i 从 1 到 n 循环重复执行 shell 脚本

android - 通过照片获取联系人信息的有效方法

javascript - NodeJS 抛出非法指令 : 4 on Mac OS