【问题标题】:Downloading Multiple Apps with AppleScript使用 AppleScript 下载多个应用程序
【发布时间】:2015-05-24 12:56:05
【问题描述】:

我想使用 AppleScript 从 iTunes 搜索结果中下载所有应用程序。

我只想下载按钮显示“获取”的应用(我不想下载付费应用或已下载的应用)。

我在下面附上了 iTunes 结果和辅助功能检查器的屏幕截图:

我已尝试使用以下代码访问 UI 元素:

tell application "System Events" to tell application process "iTunes"
    get buttons of UI elements of UI elements
end tell

任何建议都会很棒!谢谢!

【问题讨论】:

    标签: applescript ui-automation automator


    【解决方案1】:

    您需要编写一个小侦探脚本来让生活更轻松。例如,如果要获取 Playlist 列下 Music 下第一首曲目的路径:

    名称以“Down to Earth”开头的字段的“AXFrame”是x=331.00, y=125.00 etc。使用Accessibility Inspector 找出它在屏幕上的坐标并在Script Editor 中运行:

    tell application "System Events"
        tell application process "iTunes" to set frontmost to true
        delay 1
        click at {331, 125}
    end tell
    

    在结果中:

    text field 1 of row 1 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "iTunes" of application process "iTunes" of application "System Events"
    

    现在您无需向下浏览 UI 层即可获得该元素的通用路径。由于您想要获取多个元素,因此您需要能够泛化、运行循环等。

    【讨论】:

    • 因为它是一个很好的词,“侦探”,我不得不查一下它的意思(我是瑞士德语):“在侦探的方式” - ;)
    • @Zero 来自 OED 的词源:Old Norse (and Icelandic) slóð (Norwegian slod, slo) track, trail. :)
    • @Zero 我瞥见了你最后的评论。期望美国人会说“你真的希望我用方言输入字母吗?”是个好主意。 (我是美国人)
    • lol 是的,抱歉,我很快改变了看法,因为我让 NSSpeechSynthyesizer 大声说出来,使用“Henrik”和“Nora”(挪威的声音),听起来不像我想象的那么好,哈哈
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-11
    • 2011-05-28
    • 2022-10-21
    • 1970-01-01
    • 1970-01-01
    • 2014-05-14
    • 2021-08-19
    相关资源
    最近更新 更多