如何选择从iTunes中的AppleScript音箱 [英] How to select speakers for iTunes from applescript

查看:224
本文介绍了如何选择从iTunes中的AppleScript音箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想可以选择声音输出设备从脚本的iTunes(任何编程语言将是事实确定)。

I would like to be able to select output sound device for iTunes from a script (any programming language would be ok in fact).

目前我能够使用UI元素脚本起床点击这给菜单选择喇叭按钮:

For the moment I was able to use UI element scripting to get up to clicking on the button which gives the menu to select the speakers:

tell application "System Events"
     tell window "iTunes" of process "iTunes"
        set chbtn to first UI element whose help is "Choose which speakers to use."
        tell chbtn
            click
            -- tell menu 1 to get every menu item
        end tell
     end tell
end tell

这工作,并出现可能的选择菜单。然而,似乎的AppleScript后的停止点击命令,以及进一步的行动(在该评论是在code处)后,我在屏幕上点击自己的地方才会发生。我怎样才能prevent这一点,并继续从该菜单中选择菜单项?

This works, and menu with possible choices appears. However, the applescript seems to stop after the click command, and further actions (in the place where the comment is in the code) happen only after I click somewhere on the screen myself. How can I prevent this and continue to select the menu item from this menu?

没有恢复到UI脚本的任何解决方案也非常欢迎!

Any solution without reverting to UI scripting is also very welcome!

推荐答案

解决方案code是

tell application "iTunes" to activate
tell application "System Events"
    tell window "iTunes" of process "iTunes"
        click (first UI element whose help is "Choose which speakers to use.")
        keystroke "DENON" & return -- Select "DENON" airplay entry
        -- keystroke "Computer" & return -- Select standard output
     end tell
end tell

但是,之间一个恼人的4秒延迟点击击键

这篇关于如何选择从iTunes中的AppleScript音箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆