使用 Applescript UI 脚本设置电视剧集信息中的日期字段
Using Applescript UI scripting to set date field in info of TV episode
为了让它们在从 AppleTV(第 2 代)观看时正确(并且有用!)排序,我正在尝试以编程方式设置我的 iTunes 资料库中所有电视剧集的 'Release Date'。不幸的是,该字段在轨道对象上 r/o,所以我求助于通过 UI 脚本来设置它。
我已经完成了查找 UI 元素名称的发现过程,但我无法完全获得所需的元素来接受输入。它有焦点,但按键似乎没有达到它。
tell application "iTunes"
tell frontmost to activate
if selection is not {} then
set originalSelection to selection
repeat with theEpisode in originalSelection
set addedDate to (date added of theEpisode)
if (release date of theEpisode) is missing value then
tell application "System Events"
tell process "iTunes"
tell menu bar 1
tell menu bar item "Edit"
tell menu "Edit"
click menu item "Get Info"
end tell
end tell
end tell
delay 1
tell window "TV Show Info"
activate
tell scroll area 1
tell group 1
set focused of UI element 2 to true
tell window "TV Show Info" to activate
keystroke "1"
end tell
end tell
end tell
end tell
end tell
-- I'd prefer to just do this, but the property is r/o
-- set release date of theEpisode to (date added of theEpisode)
end if
end repeat
end if
end tell
其中有一些多余的、无效的、孤注一掷的尝试,以使日期字段真正成为焦点。虽然它确实被突出显示为活动元素,但它仍然不需要按键。我错过了什么?
(这是在 iTunes 12.4.1.6 上,如果有任何区别的话)
但是,在 iTunes 12.4.1.6 上是可能的,可能他们忘了在字典中更改它。
tell application "iTunes"
repeat with theEpisode in (get selection)
if (release date of theEpisode) is missing value then
set addedDate to (date added of theEpisode)
set release date of theEpisode to addedDate
end if
end repeat
end tell
为了让它们在从 AppleTV(第 2 代)观看时正确(并且有用!)排序,我正在尝试以编程方式设置我的 iTunes 资料库中所有电视剧集的 'Release Date'。不幸的是,该字段在轨道对象上 r/o,所以我求助于通过 UI 脚本来设置它。 我已经完成了查找 UI 元素名称的发现过程,但我无法完全获得所需的元素来接受输入。它有焦点,但按键似乎没有达到它。
tell application "iTunes"
tell frontmost to activate
if selection is not {} then
set originalSelection to selection
repeat with theEpisode in originalSelection
set addedDate to (date added of theEpisode)
if (release date of theEpisode) is missing value then
tell application "System Events"
tell process "iTunes"
tell menu bar 1
tell menu bar item "Edit"
tell menu "Edit"
click menu item "Get Info"
end tell
end tell
end tell
delay 1
tell window "TV Show Info"
activate
tell scroll area 1
tell group 1
set focused of UI element 2 to true
tell window "TV Show Info" to activate
keystroke "1"
end tell
end tell
end tell
end tell
end tell
-- I'd prefer to just do this, but the property is r/o
-- set release date of theEpisode to (date added of theEpisode)
end if
end repeat
end if
end tell
其中有一些多余的、无效的、孤注一掷的尝试,以使日期字段真正成为焦点。虽然它确实被突出显示为活动元素,但它仍然不需要按键。我错过了什么?
(这是在 iTunes 12.4.1.6 上,如果有任何区别的话)
但是,在 iTunes 12.4.1.6 上是可能的,可能他们忘了在字典中更改它。
tell application "iTunes"
repeat with theEpisode in (get selection)
if (release date of theEpisode) is missing value then
set addedDate to (date added of theEpisode)
set release date of theEpisode to addedDate
end if
end repeat
end tell