从 pbcopy 获取结果并使用 applescript 将它们转换为数组?

发布于 2024-09-14 17:48:53 字数 466 浏览 3 评论 0原文

我有以下代码来从文件中读取内容以打开多个 Safari 浏览器。

set locations to paragraphs of (read (choose file with prompt "Pick text file containing urls"))
repeat with aLocation in locations
    tell application "Safari" to open location aLocation
end repeat

如何从 pbcopy 读取内容(从 Command-C 操作复制的结果)?我尝试如下,但我无法得到线条,但得到字母。

try
    set the locations to Unicode text of (the clipboard as record)
on error errMsg
    display dialog errMsg
end try

I have the following code to read contents from a file to open multiple Safari browsers.

set locations to paragraphs of (read (choose file with prompt "Pick text file containing urls"))
repeat with aLocation in locations
    tell application "Safari" to open location aLocation
end repeat

How can I read contents from pbcopy (copied result from Command-C action)? I tried as follows, but I couldn't get the lines, but the alphabets.

try
    set the locations to Unicode text of (the clipboard as record)
on error errMsg
    display dialog errMsg
end try

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

从来不烧饼 2024-09-21 17:48:53

如果剪贴板包含行为 URL 的文本,您可以使用以下脚本检索这些 URL:

set locations to paragraphs of (the clipboard as Unicode text)

If the clipboard contains text whose lines are URLs, you can retrieve those URLs by using the following script:

set locations to paragraphs of (the clipboard as Unicode text)
万水千山粽是情ミ 2024-09-21 17:48:53

也许最简单的事情就是制作一个 bash 脚本,该脚本将调用 pbpaste,然后使用 osascript -e 在其中执行 applescript。

Probably the easiest thing to do is to make a bash script that will invoke pbpaste then use osascript -e to execute applescript within.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文