Automated Finder Window Capture script

Does anybody know how to capture a Finder window with any kind of screen capture software?

I need to open a Finder window with a directory listing without human intervention. (This script will be running on a headless, keyboardless, robot.) I need to capture that window [ultimately] to a PDF. And then I need to store the picture in a specified location.

I have read through a few posts about screen capture but they all require human interaction. One post suggested printing the window but the Finder doesn’t allow for printing of it’s windows.

tell application "Finder"
	activate
	select front window
end tell
set shellCommand to "/usr/sbin/screencapture -ioxT5P /Pict1.png"
do shell script shellCommand

Above, the screencapture command wants to wait for keyboard interaction.

and

set shellCommand to "/usr/sbin/screencapture -iwoxT5P /Pict1.png"
try
	with timeout of 0 seconds
		do shell script shellCommand
	end timeout
end try
tell application "Finder"
	activate
	select front window
end tell

here, the “do shell script” will NOT timeout. Thus, I cannot continue with my code and eventually issue a System Event to click in the window.

I have also trying putting screencapture in the background (&) but again, the “do shell script” still won’t timeout/release.

Are there any ideas about how this could be done?

I have used Snapz Pro in the past for this but it was difficult to use as an automated product. Does anybody know of any software that could be used to do this similar job?

Rob

Shell scripts return both their output and their exit status to your script so in order to continue your script immediately, you need to tell it to ignore all this. The “&” will mean the exit status is ignored but to ignore the output you need to pipe it elsewhere, usually to /dev/null.
set shellCommand to “/usr/sbin/screencapture -iwoxT5P /Pict1.png &> /dev/null &”

Thanks Gannet! That got me past the screencapture command.

So here is my code now:

set shellCommand to "/usr/sbin/screencapture -iwo /Pict1.png &> /dev/null &"
do shell script shellCommand
tell application "Finder"
	activate
	select front window
	set WindowPosition to position of front window
end tell
delay 2
tell application "System Events"
	tell process "Finder"
		click at {(item 1 of WindowPosition) + 5, (item 2 of WindowPosition) + 10}
	end tell
end tell

First problem: The Finder process doesn’t recognize the “click at” command AT ALL.
Second problem: Even if it does (because I setup a QuicKey shortcut to take the “click at” place,) screencapture won’t recognize anything other than a click of the mouse.

Anybody have any more ideas about how I can capture a Finder window?

Rob

Hi
try finder select,system events click or system events shortcut keys
bills

Bills,

I thought that was what I was doing with the ‘select front window’ or ‘click at’ commands. I guess I don’t know what you are talking about. Please expound on your suggestion.

Rob

Hi
Sorry I was running a script of desktop when i replied to you,didn’t have access to script editor.
Finder recognizes select, system events recognizes the keyed commands

tell application "Finder"
	select (item 1 of WindowPosition) + 5
	tell application "System Events"
		click
	end tell
end tell

You can use finder to find and select a file, and any other application to open the file.
I am not sure I’ve answered your question, explanations is not my strong point.
hope it helps
bills