google-chrome - Chrome,Youtube和AppleScript

标签 google-chrome youtube applescript

我正在尝试使用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/

相关文章:

google-chrome - 在 Firefox 和 chrome 中以隐身模式或非隐私模式从浏览器的隐私模式打开书签

javascript - Chrome 扩展程序 : Open tab, 转到 url,填写表格并提交表格

html - 滚动捕捉 CSS 跳过元素

objective-c - 返回大值的 NSUserAppleScriptTask 从不调用completionHandler

dialog - Applescript 中的非阻塞对话框

python - Google Chrome 和 selenium webdriver 无法按预期工作

Youtube V3 - LiveChatMessages.list 最多仅返回 75 个请求

Angular/YouTube API - 拒绝显示 : in a frame because it set 'X-Frame-Options' to 'sameorigin

flash - YouTube ActionScript 2.0 Player API无法正常工作

user-interface - 在 AppleScript 中选择弹出菜单按钮