You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用AppleScript设置热键,在Word/Pages打字时后台控制VLC?

后台控制VLC/QuickTime播放的AppleScript方案

VLC Media Player 实现步骤

1. 开启VLC的AppleScript支持

打开VLC → 偏好设置 → 界面 → 主界面,勾选AppleScript选项,重启VLC生效。

2. 各功能的AppleScript代码

直接复制以下代码,配合热键工具(如Spark)使用:

  • 播放/暂停
tell application "VLC" to playpause
  • 回退5秒
tell application "VLC"
    if exists current item then
        set current time of current item to (current time of current item) - 5
    end if
end tell
  • 前进5秒
tell application "VLC"
    if exists current item then
        set current time of current item to (current time of current item) + 5
    end if
end tell
  • 快退(慢放,速率0.5x)
tell application "VLC" to set rate to 0.5

如果需要倒放,将代码改为 tell application "VLC" to set rate to -1

  • 快进(加速,速率2x)
tell application "VLC" to set rate to 2

3. 用Spark绑定热键

打开Spark → 点击「+」新建快捷方式 → 选择「AppleScript」类型 → 粘贴对应代码 → 设置触发热键(例如:播放/暂停用 Cmd+Opt+P,回退5秒用 Cmd+Opt+←)。


QuickTime Player 修正方案

你之前的代码问题在于时间单位(QuickTime用毫秒)和命令细节,以下是正确代码:

  • 播放/暂停
tell application "QuickTime Player"
    if exists document 1 then
        if playing of document 1 is true then
            pause document 1
        else
            play document 1
        end if
    end if
end tell
  • 回退5秒
tell application "QuickTime Player"
    if exists document 1 then
        set current time of document 1 to (current time of document 1) - 5000
    end if
end tell
  • 前进5秒
tell application "QuickTime Player"
    if exists document 1 then
        set current time of document 1 to (current time of document 1) + 5000
    end if
end tell
  • 快退(慢放0.5x)
tell application "QuickTime Player"
    if exists document 1 then
        set rate of document 1 to 0.5
    end if
end tell
  • 快进(加速2x)
tell application "QuickTime Player"
    if exists document 1 then
        set rate of document 1 to 2
    end if
end tell

同样用Spark绑定热键即可,代码中加入了「检查文档是否存在」的判断,避免无视频打开时报错。


内容的提问来源于stack exchange,提问作者topical_writing

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 16:15:52