我正在尝试使用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视频?
我绝对不是程序员,这也是我第一次使用Apple脚本!
最佳答案
一个不错的练习是验证输入。 (在对话框接受答案并继续下一个命令之前,请确保用户文本符合要求的格式)。
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
关于google-chrome - Chrome,Youtube和AppleScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15260293/