我正在尝试与 iTunes“导出库..”对话框进行交互。
我尝试“将选项设置为窗口 winName 的组 1 的弹出按钮 1 的菜单 1 的每个菜单项”,但它说“组 1”是无效索引?
相关代码如下:(调用参数为:“iMac-8GB”、“iTunes”、“iTunes”、false”
on handleDir(dir, winName, appName, createIt)
local foundIt, ndx
set foundIt to false
if winName is not "" then
tell application "System Events" to tell process "iTunes"
set choices to every menu item of menu 1 of pop up button 1 of group 1 of window winName
您想使用 iTunes 中的“导出库...”菜单:
第一步是选择相关菜单。在我的 iTunes 版本 (12.5.5.5) 中,菜单位于“文件”菜单、子菜单项“库”,然后是子菜单“导出库...”。
第二步填写导出文件名并设置目标文件夹。 Mac 的“另存为...”窗口有许多快捷方式,对所有应用程序都有效。其中,命令 G 允许定义保存文件的完整路径。该路径必须采用 Unix 格式(子级别使用“/”而不是“:”)。
下面的脚本执行完整的导出库功能。前两行定义要保存的文件的名称以及保存路径。根据您的需要调整它们。
set myTitle to "test" -- name of the exported file
set myPath to "/Users/myuser/Desktop/Test_folder" -- destination folder for export file
tell application "iTunes" to activate -- make iTunes front
tell application "System Events"
tell process "iTunes"
click menu 3 of menu bar 1 -- open the File menu
click menu item 12 of menu 3 of menu bar 1 -- select the Library menu item
delay 0.1
click menu item 5 of menu 1 of menu item 12 of menu 3 of menu bar 1 -- select the export library… item
delay 0.1
keystroke myTitle -- fill the export file name in the save as… dialog
keystroke "G" using command down -- shortcut to open Go-to folder window
keystroke myPath
keystroke return -- to close the go-to window
delay 0.1
keystroke return -- to close the export window
end tell -- process iTunes
end tell -- system Events
我添加了一些延迟,以确保您的 Mac 有足够的时间打开或关闭窗口。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)