I’ve found where you can issue a shell command using AppleScript to do a screen capture of the entire screen. But does anyone know how to capture just a select window?
I’m wanting to do a screen capture of a Safari window, then take that screen capture and crop out just the section I need. I’ve already figured out how to do the crop, but I can’t find out how to just do the Safari window and not the entire screen.
As you can probably see from the man page for [screencapture] in the Terminal, the documentation is pretty crummy for this command, cool though it is. This code works, but does require some interaction from the user:
display dialog "Place the cross in the window you want, press the space bar to select, and press the mouse button to capture."
do shell script "screencapture -iw ~/desktop/screen01.png"
Incidentally, the window you select DOES NOT need to be in the front, and ONLY the selected window is captured, regardless of what happens to be in front of the selected window.
Ok, I guess I need to give little more of the details of what I’m doing. And yes, I do know how to do a screen capture manually. This script will run on it’s own, on a dedicated computer, and can not depend on any human interaction.
This will be automated AppleScript running through several thousand web pages and I’m wanting to take screen shots of each one. I know there are other methods of saving stuff like this, like curling the html source. But I need a screen shot frozen in time and not dependent on information not being there months later.
So let’s say instead of using a shell command and calling system events, what would the AppleScript command look like doing “keystroke” with two modifier keys down. CMD-SHIFT-4
<keystroke “4” using command and shift down> doesn’t work
Thank you everyone for your recommendations and suggestions. I think I have enough information to complete what I’m trying to do, but if anyone has any more ideas, I will definitely appreciate it. I have learned long time ago that there are many ways to accomplish a simple task in any programming language.