如何编程抓取以捕获applescript xcode中的窗口

时间:2013-01-30 17:16:37

标签: xcode window applescript

我需要让应用程序“抓取”在xcode 3.2中使用applescript捕获一个窗口。这可能是什么剧本?

2 个答案:

答案 0 :(得分:1)

我没有在AppleScript World中找到任何直接可用的东西,所以我建议使用screencapture - 一个命令行工具 - 并从你的脚本中调用它。 在 Terminal.app 中执行man screencapture以查看其手动操作。

Side-Note:执行shell脚本编写的AppleScript Command是do shell script(来自“StandardAdditions”)。

(“Grab”不支持AppleScript)

答案 1 :(得分:1)

以下applescript代码将截取屏幕一部分的屏幕截图,并将其保存到桌面上的文件中。如上所述,它使用屏幕截图应用程序。

set x1 to 0
set x1 to x1 + 1
set thename to "screencapture -x -R20,20,640,380 ~/Desktop/screen_" & x1 & ".png"

tell application "Terminal"

activate

do script thename in window 1

end tell