1

我正在尝试使用 applescript 设置 youtube 视频播放点。例如,当您在此视频中按 0 - 9 键时,播放点会发生变化。

我已经设法用这个告诉 chrome 击​​键 1

tell application "Google Chrome"
    activate
tell application "System Events" to tell process "Google Chrome" to key code 83
end tell

它返回一个 1,但只有地址栏被突出显示。所以我的问题是,我如何专注于 youtube 视频?

我绝对不是程序员,这也是我第一次使用苹果脚本!

4

2 回答 2

1

对您来说,一个很好的练习是验证输入。(确保用户文本符合要求的格式,然后对话框接受答案并继续执行下一个命令)。

set videoUrl to "https://www.youtube.com/watch?v=o6xchtAsq4U"
set AppleScript's text item delimiters to ":"
set {min, sec} to text items of (text returned of (display dialog "Enter start time… minutes:seconds" default answer "1:15"))
set AppleScript's text item delimiters to {""}

tell application "Google Chrome"
    if not (exists window 1) then reopen
    set URL of active tab of window 1 to videoUrl & "&t=" & min & "m" & sec & "s"
end tell
于 2013-03-07T00:35:00.650 回答
0

Maybe try and use keystroke tab to tab its way to the video instead of address bar Make sure you put this at the start after page load.

于 2013-03-07T00:00:31.217 回答