苹果脚本与消息采取行动的URL



我正在尝试为消息编写AppleScript,这样,如果我收到包含URL的消息,脚本会自动在浏览器中打开链接。

我已经可以设置一个脚本来运行,它会向我发送一个带有消息属性的通知,但我还不知道如何对URL执行操作。

以下是我所能生产的:

using terms from application "Messages"
    on message received from theSender for theChat with theContents
      display notification theContents as text ¬
          with title "New Message from " & theSender
    end on message received
end using terms

以下是一个可能对您有所帮助的示例:

set msg to theContents as text
set AppleScript's text item delimiters to space
set msg to msg as list
repeat with x in items of msg
    if "http" is in x then
        display dialog x
    end if
end repeat

最新更新