在使用Apple脚本进行自动化时,如何使用QuickTime Player使用QuickTime Player并将其保存到MacOS中的剪贴板?
我是一个Uni学生参加在线课程,我每次按下命令+ contrance +shift+4进行笔记,然后i paste 概念。,但它每次都不有效 ,然后我发现 QuickTime播放器将保持相同的区域要捕获部分屏幕截图,因此我决定使用Apple脚本来完成操作。
我编写的代码可以切换到应用程序 QuickTime Player ,然后通过按Command+Control+N进行菜单中的“新屏幕记录”,但问题是有时按两次空间按将呼唤“捕获选定的窗口”,而不是“捕获选定的部分”。同时,尽管我已经勾选了“记住最后选择”,但保存屏幕截图的位置也将更改,也许可以重置要保存的位置每次都是必不可少的。
on run {input, parameters}
activate application "QuickTime Player"
tell application "System Events"
key code 45 using {command down, control down}
delay 0.1
# Switch to "Capture Select Portion" by pressing SPACE
repeat 2 times
key code 49
delay 0.1
end repeat
# Press ENTER to capture a screenshot
key code 35
delay 0.1
end tell
return input
end run
我花了几个小时找到存在的文章,但也许不是满足我的需求。
做shell脚本“ screencapture -ci”
与按命令+控制+shift+4,i 必须手动选择部分。
做shell脚本“ screencapture -x -r20,20,20,640,380〜/desktop/test.png”
需要精确的坐标。,但是坐标是可变的,因为窗口未固定,并且需要通过使用外部软件找到它,也许有点不高。 如果没有解决方案,我将使用它,因为它比每次选择部分都更方便。
很抱歉在这里粘贴他人的代码,并说出为什么他们不适合我,我只是想明确说明...谢谢您的阅读,有美好的一天,无论您是否愿意提供帮助me ^ ^
关于将屏幕截图粘贴到概念有效的部分,所以我没有在这里粘贴它。
I'm a uni student taking online courses, I take portion screenshots by pressing Command+Control+Shift+4 every time to take notes, then I paste it to Notion. But it's not efficient to select the same area every time, then I found that QuickTime Player will keep the same area for capturing a portion screenshot, so I decided to use Apple Script to complete the operation.
The code I wrote could switch to the application QuickTime Player and then proceed to "New Screen Recording" in the menu by pressing Command+Control+N, but the problem is that sometimes pressing twice space will call out "Capture Selected Window" instead of "Capture Selected Portion". Meanwhile, the location where saving the screenshots will also be changed too though I already ticked "Remember Last Selection", maybe resetting the location to be saved every time is essential.
on run {input, parameters}
activate application "QuickTime Player"
tell application "System Events"
key code 45 using {command down, control down}
delay 0.1
# Switch to "Capture Select Portion" by pressing SPACE
repeat 2 times
key code 49
delay 0.1
end repeat
# Press ENTER to capture a screenshot
key code 35
delay 0.1
end tell
return input
end run
I spent a few hours finding the existed articles but perhaps not that fulfill my needs.
do shell script "screencapture -ci"
is as same as pressing Command+Control+Shift+4, and I have to select the portion manually.
do shell script "screencapture -x -R20,20,640,380 ~/Desktop/test.png"
needs a precise coordinate. But the coordinate is variable since the window is not fixed, and it needs to be found by using external software, maybe it's a little bit not efficient. If there is no solution for that, I will use it since it's much more convenient than selecting the portion every time.
Sorry about pasting others' code here and saying why they r not suitable for me, I just wanted to make it clear... Thanks for reading here, have a nice day no matter if u r willing to help me ^ ^
The part about pasting screenshots to Notion works, so I didn't paste it here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我尝试编写一些东西,它有效,但仍然有一些错误
。 bar 由于我没有通过使用
整个内容
而成功地找到该元素。您在使用过程中无法移动鼠标,或可能导致错误:
系统事件发生错误:无法获取菜单\“ options \” button \“ options \”选项\ of Application Process \“ of window \”窗口\“ screenCaptureui \”
。将保存屏幕截图,可能需要几秒钟的时间才能让程序找到菜单项剪贴板。
希望这对某人有所帮助,如果您有任何想法,请随意修改它,因为它仍然有错误。
I tried writing something, it works but still has some bugs.
For example, the coordinate of the menu "Options" should be initialized depending on the precise location of the bar since I didn't succeed in finding the element by using
entire contents
.You can't move your mouse during the use, or it might cause an error:
System Events got an error: Can’t get menu \"Options\" of button \"Options\" of window \"Window\" of application process \"screencaptureui\"." number -1728 from menu "Options" of button "Options" of window "Window" of application process "screencaptureui
When selecting the path where screenshots will be saved, it might take a few seconds to let the program find the menu item Clipboard.
Hope this helps someone, if u hv any idea plz feel free to modify it since it still has bugs.
您不需要快速时间来保留确切的尺寸窗口。实用程序文件夹中的屏幕截图通过将您设置在窗口中的最后一个选项自动执行此操作。您要做的就是按捕获。优势是您可以根据需要进行调整。一个人永远不知道。
您不需要脚本来执行此操作,但是,如果您想将屏幕截图放在码头中,它会保留码头显示,如果您想要的图片在码头下方会很糟糕。
You don't need QuickTime to keep the exact size window. Screenshot in the Utilities folder does this automatically, by keeping the last options you set in the window. All you have to do is press Capture. The advantage is you can adjust IF you need. One never knows.
You don't need a script to do this, BUT, if you want to put Screenshot in the Dock, it keeps the Dock showing, which sucks if the pic you want is under the Dock.