【问题标题】:Apple Script Editor to prevent QuickTime opening full screenApple Script Editor 防止 QuickTime 全屏打开
【发布时间】:2020-09-08 17:46:59
【问题描述】:

我正在尝试使用脚本编辑器编写一个应用程序,以便在我的 Mac 启动时运行,以便它播放视频然后关闭应用程序。但我不希望它进入全屏模式,这是它自动执行的操作。这是我迄今为止尝试过的(即在 QuickTime 上“适合屏幕”)......有什么建议可以代替吗?

tell application "System Events" to keystroke "3" using command down

【问题讨论】:

    标签: applescript quicktime


    【解决方案1】:

    您不需要为此使用系统事件。根据您的描述,这是一个您可以控制的视频 - 您或许可以对其进行编辑并重新保存?

    我知道过去可以在 Quicktime 播放器中使用 AppleScript 设置(或取消设置)“全屏”标志。它甚至可以在 GUI 中实现。

    刚刚检查:该属性称为“呈现”,因此您可以执行以下操作:

    tell application "QuickTime Player"
        activate
        tell (open file "xyz.m4v")
            set the presenting to false -- disable full screen playback
            play
        end tell
    end tell
    

    快速提示:如果您使用的是 Mac OS High Sierra 或更早版本,则可以从https://support.apple.com/kb/dl923 安装 QuickTime Player 7。这将允许您播放上世纪数十种异国情调的传统多媒体文件格式,如果您输入 Pro 键,您将能够对曲目和时间线进行简单的编辑,包括设置全屏标志。如果您这样做,则保存视频(使用新名称)。下次打开该视频时,它不应再全屏显示。

    让播放器在视频播放完毕后退出比较棘手,但也许您有解决方案。如果没有,您可以将其保存为 AppleScript 应用程序设置为保持打开状态,它会在空闲时每秒轮询一次 QuickTime Player 播放的状态(这是最大速率)。电影结束后,AppleScript 可以关闭 QuickTime Player 并退出。完整的脚本是这样的:

    tell application "QuickTime Player"
        activate
        tell (open file "Macintosh HD:Users:Laura:Movies:xyz.m4v")
            set the presenting to false -- disable full screen playback
            play
        end tell
    end tell
    on idle
        tell application "QuickTime Player"
    
            if document 1 exists then
                tell document 1
                    if (not playing) and (current time > (duration - 1)) then
                        quit
                        tell me to quit -- quit the AppleScript itself
                    end if
                end tell
            else -- no movie open, perhaps it failed, or got moved
                tell me to quit -- just quit the AppleScript
            end if
    
        return 1 -- i.e. poll once per second (maximum)
    end tell
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-13
      • 2014-07-12
      • 2014-11-08
      • 2011-12-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多