在applescript中设置时间代码

在applescript中设置时间代码,applescript,timecodes,Applescript,Timecodes,我使用applescript远程Aegisub来按时间移动视频字幕时间轴。请看图片。 以下是我使用的代码: tell application "Aegisub" activate delay 0.1 end tell tell application "System Events" tell process "Aegisub" keystroke "i" using command down --cmd+i open "shift by" windo

我使用applescript远程Aegisub来按时间移动视频字幕时间轴。请看图片。

以下是我使用的代码:

tell application "Aegisub"
    activate
    delay 0.1
end tell
tell application "System Events"
    tell process "Aegisub"
        keystroke "i" using command down   --cmd+i open "shift by" window
        delay 0.3
        click radio button "Time: " of window "Shift Times"   --choose shift by time not frames
        delay 0.3
        set the value of text field 1 of window "Shift Times" to "0:00:00.20" --set up shift how long time
        click radio button "Forward" of window "Shift Times"    --forward or backward
        click radio button "Selection onward" of group "Affect" of window "Shift Times"
        delay 0.3
        click button "OK" of window "Shift Times"
    end tell
end tell
请注意这一行:

set the value of text field 1 of window "Shift Times" to "0:00:00.20"
它会将文本字段1的屏幕值更改为“0:00:00.20”。但实际上,它会根据您上次使用的值来改变时间。
如果您用键盘手动输入“0:00:00.20”,它将按时间“0:00:00.20”移动。只有这条线在这里不行。 看起来它和时间码的格式有关。 请注意,应用程序使用的时间码是“0:00:00.20”,而不是“0:00:00:20”。
希望有人能帮助我。

当您在文本输入框中输入一个值时(取决于界面编程人员的注意力),在文本输入框失去焦点之前,该值可能不会从界面发送到基础模型:例如,键入
return
键时,单击另一个UI元素的。在编写接口脚本时,这种焦点转移可能会发生,也可能不会发生(也可能不会以相同的方式发生),因此您可能希望直接调用它,如下所示:

    set the value of text field 1 of window "Shift Times" to "0:00:00.20" --set up shift how long time
    click radio button "Forward" of window "Shift Times" --forward or backward
    click radio button "Selection onward" of group "Affect" of window "Shift Times"
    delay 0.3
    tell button "OK" of window "Shift Times"
        set focused to true
        click
    end tell

我终于找到了答案。我需要使用按键输入一位一位的值,就像我用键盘做的一样。在@Ted Wrigley的回答中,按钮“OK”的告诉-结束-告诉结构启发了我。这里是正确的代码

tell application "Aegisub"
    activate
    delay 0.1
end tell
tell application "System Events"
    tell process "Aegisub"
        set stime to "0000020"

        keystroke "i" using command down --cmd+i open "shift by" window
        delay 0.3
        click radio button "Time: " of window "Shift Times" --choose shift by time not frames
        delay 0.3

        tell text field 1 of window "Shift Times"
            set focused to true
            keystroke stime
        end tell

        click radio button "Forward" of window "Shift Times" --forward or backward
        click radio button "Selection onward" of group "Affect" of window "Shift Times"
        delay 0.3
        click button "OK" of window "Shift Times"
    end tell
end tell

请注意,屏幕上的时间码格式为“0:00:00.20”,但时间码的格式必须为“0000020”。

谢谢您的回答。不幸的是,它不起作用。是否有一个免费的应用程序副本可以在某个地方进行测试?这是一个免费的应用程序。你可以在他们的官方网站上下载。