Searching fro a screen shot solution.

We are attempting to be able to send out email proofs from our stationery business and are looking for a solution that will help automate the process.

Basically what we are looking for is a solution that will require the typesetter to input a name into a prompt and that name will automatically become the filename of the screen capture and send it off to a designated network folder.

Does this solution currently exist? Is it something someone could help me through?

Built into the system: see man screencapture. The following will create a png file on your desktop (for illustration) of the contents of a window (-W) in interactive mode (the added i). When you run it, the cursor turns to a camera and when you click over a window its contents are captured:

-- set Dest to choose folder
set Ttl to (text returned of (display dialog "Choose a name for the output file. A .png extension will be added so do not include an extension." default answer "ScreenShot")) & ".png"
set Dest to ((path to desktop folder as text) & Ttl)
do shell script "screencapture -Wi " & quoted form of POSIX path of Dest

Hi,

Taking a read of this page (the first result from Googling “applescript screen capture”):
http://bbs.applescript.net/viewtopic.php?id=11359

I knocked together:

set target_folder to (path to desktop) as string
set file_name to text returned of (display dialog "Select file title." default answer "") & ".png"
try
	do shell script "/usr/sbin/screencapture -x " & ((quoted form of POSIX path of target_folder & file_name) as string)
on error theErr
	display dialog theErr
end try

You’d need to set target_folder to the path to your designated network folder.

As screencapture seems to overwrite files without confirmation, you’ll want to check if there is a file of that name beforehand. See the original script for a way to do this.

John M

I appreciate the quick replies.

John that script seems to be getting extremely close to what I am attempting to find.

The only difference being that we will have to have our result be a selection capture instead of an entire screen grab.

Would it be possible to use this script to bring up a selection capture?

Thank you for the assistance.

Did you enter ‘man screencapture’ in the Terminal as Adam suggested?

Try:

set target_folder to (path to desktop) as string
set file_name to text returned of (display dialog "Enter file title." default answer "") & ".png"
try
	do shell script "/usr/sbin/screencapture -iW " & ((quoted form of POSIX path of target_folder & file_name) as string)
on error theErr
	display dialog theErr
end try

John M

for a selection (not a window) use the flag s

.
	do shell script "/usr/sbin/screencapture -is " & ((quoted form of POSIX path of target_folder & file_name) as string)
.

I suppose my reading peoples posts correctly could help as well. :wink:

John M

Thank you very much for the assistance, that kicked out exactly the results I was hoping for (combining John’s script with StefanK’s change).

I apologize for the novice approach to this topic. We were hoping for a built in solution, but had no idea how to approach it.

I have a moderately related question - is there a way to setup this script to run via a shortcut key?

If it is time for me to buzz off I understand, but thanks again for the help.

A hot key solution requires a third-party application of which there are many, but only a few are free: see the Keyboard Shortcuts pane of the Keyboard and Mouse system preference for the Apple supplied version. There you can assign a hot key to an application, so you would have to save the script as an application and then wait for it to open and run.

Others include: QuicKeys, QuickSilver (free but a learning curve), FastScripts, LaunchBar. These can launch a script that runs in the background except for dialog boxes, etc. You could also turn it into an Automator Action.

No, Sir, you can only assign a hot key to a menu entry of an application

You can tell I’ve never used it, Stefan :rolleyes:, I use FastScripts for some and Quicksilver for others.

I use Spark which is free and very easy to use. :slight_smile:

We have run into a problem with this script. It was obviously a problem all along, but we just recently noticed it.

The script we are using is…

set target_folder to ("/Volumes/Invitations-Shared ( 1 )/EMAIL PROOFING/") as string
set file_name to text returned of (display dialog "Enter file title." default answer "") & ".jpg"
try
	do shell script "/usr/sbin/screencapture -is " & ((quoted form of POSIX path of target_folder & file_name) as string)
on error theErr
	display dialog theErr
end try

I have also used the following terminal command on every computer where this script is being used

defaults write com.apple.screencapture type jpg

Here is the problem

Though we’ve changed the default screencapture type to jpg and the script is telling the file to save with a .jpg extension the file is actually being saved as a PNG. We discovered this because Photoshop doesn’t recognize the file and preview sees it as a PNG even though the extension is JPG

I know the terminal command works because SHIFT+APPLE+4 does result in a legitimate JPG file.

Any thoughts on this?

form the man page

[i]NAME
screencapture – capture and manipulate clipboard contents

SYNOPSIS
screencapture [-SWCTMPcimswxt] file

DESCRIPTION
The screencapture utility is not very well documented to date. A list of options follows.
.

-t Image format to create, default is png (other options include pdf, jpg, tiff and other formats).

.[/i]

that was the ticket!

Thanks for the assist