applescript - Apple Script Editor 防止 QuickTime 全屏打开
问题描述
我正在尝试使用脚本编辑器编写一个应用程序,以便在我的 Mac 启动时运行,以便它播放视频然后关闭应用程序。但我不希望它进入全屏模式,这是它自动执行的操作。这是我迄今为止尝试过的(即在 QuickTime 上“适合屏幕”)......关于如何做的任何建议?
tell application "System Events" to keystroke "3" using command down
解决方案
您不需要为此使用系统事件。根据您的描述,这是一个您可以控制的视频-您也许可以对其进行编辑并重新保存?
我知道过去可以在 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
推荐阅读
- java - Java多线程变量可见性问题
- c# - 没有这样的列:EPF(代码 1 SQLITE_ERROR)Xamarin android
- python - 在导入其他模块之前设置日志记录
- javascript - 如何在javascript中将日期时间“2020-12-14 16:07:09”转换为“9 Jan 2020”?
- python - 'DataFrameGroupBy' 对象没有属性 'set_index'
- python - 在 Python 中使用 tn.read 阅读
- r - R renv 包创建子文件夹“staging” - 这些可以被删除而没有危险吗?
- java - 意外的输入结束:Array ElasticSearch 的预期关闭标记
- oracle - SQL Developer 使用 join 命令删除一行
- amazon-web-services - AWS Connect API - 创建联系流