Script to capture a window...
Script to capture a window...
- Subject: Script to capture a window...
- From: David Crowe <email@hidden>
- Date: Fri, 10 Dec 2010 09:31:50 -1000
Title: Script to capture a window...
This script streamlines the process of capturing a window into a
file, especially if the script is linked to a hot key.
All you need to do is to choose the file name, select the window
and click.
------------------------------------- START SCRIPT
---------------------
--
-- Grab Window. Takes a snapshot of any visible window and saves into
the chosen file
--
-- Bug: Does not add an extension, this must be done manually
--
-- (c) 2010 David Crowe. May be freely used, distributed and
incorporated in any products with credit.
--
property lastlocation : ""
activate
try
if
lastlocation = "" then
choose file name
with prompt
"Choose name and
location of .PNG file to contain image of selected
window."
else
choose file name
with prompt
"Choose name and
location of .PNG file to contain image of selected
window." default location alias lastlocation
end if
on
error
errmsg number errnum
if
errnum -128
then -- User
cancelled
display
dialog "Cannot select file for window
capture. " &
errmsg & "
(" & errnum &
")"
end
if
return
end try
set theFile to the result
set AppleScript's text
item delimiters
to ":"
set theFolder to
(reverse of rest
of reverse of every text item of
(theFile
as string)) as
string
set thePosixFile to
POSIX path
of theFile
if thePosixFile does not end with ".png"
and
thePosixFile does not
end with
".PNG" then set thePosixFile to
thePosixFile & ".png"
set s to
"screencapture -iW
'" & thePosixFile
& "'"
try
do shell script s
on
error
errmsg number errnum
display dialog "Cannot capture window. " & errmsg & " (" & errnum & ")"
end try
set lastlocation to
theFolder
------------------------------------- END SCRIPT
---------------------
- David Crowe
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden