我正在尝试编写一个 Applescript 来使用创建网络音频连接音频 MIDI 设置(/应用程序/实用程序/音频 MIDI 设置.app)。我无法打开网络设置窗口。似乎有一个图像,我必须单击它才能打开网络窗口。
这是我尝试过的:
tell application "System Events"
tell process "Audio MIDI Setup"
set {xPos, yPos} to position of image 1 of group 1 of scroll area 1 of window "MIDI Studio"
end tell
end tell
tell me to do shell script "/usr/bin/cliclick c:" & xPos & "," & yPos
click at {xPos, yPos} --image "Network" of group 1 of scroll area 1 of window "MIDI Studio"
delay 0.1
--click image "Network" of group 1 of scroll area 1 of window "MIDI Studio"
答案1
你是对的,你提到的图像有一个与之关联的 AppleScript 操作,它应该打开MIDI 网络设置窗口,但实际上,它什么也不做。
因此,作为一种解决方法,打开MIDI 网络设置窗口,试试这个:
tell application "Audio MIDI Setup" to activate
tell application "System Events" to tell process "Audio MIDI Setup"
(******************Variable declarations for GUI objects*******************)
set _W to a reference to (every window whose ¬
description contains "floating window" and ¬
name is not "MIDI Network Setup")
set select_all_menu_item to ¬
a reference to menu item "Select All" of ¬
menu 1 of ¬
menu bar item "Edit" of ¬
menu bar 1
set show_midi_studio_menu_item to ¬
a reference to menu item "Show MIDI Studio" of ¬
menu 1 of ¬
menu bar item "Window" of ¬
menu bar 1
set midi_studio_window to a reference to window "MIDI Studio"
set midi_studio_toolbar to a reference to toolbar 1 of midi_studio_window
set midi_studio_images to a reference to images of ¬
group 1 of ¬
scroll area 1 of ¬
midi_studio_window
set show_info_button to a reference to (the first button of ¬
midi_studio_toolbar whose description is "Show Info")
(**********************End of variable declarations************************)
if not (midi_studio_window exists) then click show_midi_studio_menu_item
tell midi_studio_window to perform action "AXRaise" -- bring window to front
if the front window is midi_studio_window then
tell select_all_menu_item to if it exists then click it
--OR: keystroke "a" using command down
if the show_info_button is enabled then
click the show_info_button
click (every button of _W whose subrole is "AXCloseButton")
tell window "MIDI Network Setup" to perform action "AXRaise"
end if
end if
end tell
如果您对此有任何问题,请发表评论,我会回复您。否则,请考虑选择此答案,以帮助指导其他遇到类似问题的用户。
答案2
我无法让你的脚本工作,它没有打开“MIDI 网络设置”窗口,我不得不在下面的行中将“描述”更改为“标题”,将 show_info_button 设置为对(¬ midi_studio_toolbar 的第一个按钮,其描述为“显示信息”)的引用
答案3
该脚本正在执行以下任务:告诉应用程序“音频 MIDI 设置”激活告诉应用程序“系统事件”告诉进程“音频 MIDI 设置”告诉菜单栏 1 的菜单项 2 菜单栏 1 的项“窗口”
if name is "Show MIDI Studio" then click
end tell
end tell
tell process "Audio MIDI Setup"
set {xPos, yPos} to position of image "Network (Online)" of group 1 of scroll area 1 of window "MIDI Studio"
do shell script "/usr/local/bin/cliclick dc:" & xPos & "," & yPos & ""
end tell
结束告诉告诉应用程序“音频 MIDI 设置”退出