Macos 如何在可访问性检查器描述为“的窗口中引用对象?”&书信电报;空描述>;(组)[NSBox]”;在Applescript中?

Macos 如何在可访问性检查器描述为“的窗口中引用对象?”&书信电报;空描述>;(组)[NSBox]”;在Applescript中?,macos,applescript,Macos,Applescript,我正在尝试与iTunes的“导出库…”对话框交互 我尝试过“设置窗口winName组1的弹出按钮1的菜单1的每个菜单项的选项”,但它说“组1”是无效的索引 以下是相关代码:(调用参数为:“iMac-8GB”、“iTunes”、“iTunes”和“false” 您想使用iTunes中的“导出库…”菜单: 第一步是选择相关菜单。在我的iTunes版本(12.5.5.5)中,菜单位于“文件”菜单、子菜单项“库”,然后是子菜单“导出库…” 第二步是填写导出文件名并设置目标文件夹。Mac“另存为…”窗口有

我正在尝试与iTunes的“导出库…”对话框交互

我尝试过“设置窗口winName组1的弹出按钮1的菜单1的每个菜单项的选项”,但它说“组1”是无效的索引

以下是相关代码:(调用参数为:“iMac-8GB”、“iTunes”、“iTunes”和“false”

您想使用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电脑有足够的时间打开或关闭窗口。

您想使用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电脑有足够的时间打开或关闭窗口。

使用此代码,修改为专门针对iTunes':

tell application "System Events"
    tell front window of (first application process whose frontmost is true)
        set uiElems to entire contents
    end tell
end tell
这来自于对


我发现一个NSBox被Applescript称为“大纲”。

使用这段代码,专门针对iTunes进行了修改:

tell application "System Events"
    tell front window of (first application process whose frontmost is true)
        set uiElems to entire contents
    end tell
end tell
这来自于对


我发现一个NSBox被Applescript称为“大纲”。

您可能想定义一个不同的文件夹以导出到其中。然后通过击键使用快捷命令G。然后“击键”要保存的路径和“击键”“输入键以关闭对话框。文件夹的路径必须是unix格式:folder/subfolder/@pbell-我不明白您所说的“使用快捷方式命令G”是什么意思”?我熟悉击键,但我知道没有快捷键命令G。你能提供一个带有示例代码的答案吗?你可能想定义一个要导出到的不同文件夹。然后通过击键使用快捷键命令G。然后你“击键”要保存的路径并“击键”输入key关闭对话框。文件夹的路径必须是unix格式:folder/subfolder/@pbell-我不明白你说的“使用快捷方式命令G”是什么意思?我熟悉击键,但我知道没有快捷键命令G。你能用示例代码提供答案吗?你的代码需要修改才能在我的系统上工作,因为一些数字引用不正确。我修改的版本按名称引用了所有内容,并且工作正常。感谢你的想法和samp你是对的,使用名称而不是数字使脚本更容易阅读,但我更喜欢使用数字和添加注释,因为它与语言无关:菜单名“File”只有英文版才正确,但菜单3总是正确的!我很高兴它能帮助您。您的代码需要修改才能在我的系统上工作,因为一些数字引用不正确。我修改的版本按名称引用了所有内容,并且工作正常。感谢您的想法和示例代码将我推到正确的方向。您是的,使用名称而不是数字使脚本更容易阅读,但我更喜欢使用数字和添加注释,因为它与语言无关:菜单名“File”仅在英语中是正确的,但菜单3总是正确的!我很高兴它对您有所帮助。