set a single keyboard shortcut for screenshot of frontmost window

Don’t see how to do this with the Keyboard sys pref, so…

Anyone have thoughts on how to reconfigure the shortcut to take a screenshot of (only) the frontmost window?

Command Shift 4 plus spacebar gets old when you do it 20 or 30 times in a row…

try this AutoFetishist, save as an application, just alter the delay and amount of shots to suit

set dFolder to "~/Desktop/screencapture/"
do shell script ("mkdir -p " & dFolder)
repeat 20 times -- alter repeat to suit
	set tTime to do shell script "date +%H%M%S"
	do shell script ("screencapture -i -w " & dFolder & tTime & ".png")
	delay 2 --alter to suit
end repeat

or, if you wanted to have more input into how many repeat times you want to capture:

set dFolder to "~/Desktop/screencapture/"
do shell script ("mkdir -p " & dFolder)
set RepeatAmount to text returned of (display dialog "How many times to repeat capture?" default answer "20")
repeat RepeatAmount times -- alter repeat to suit
	set tTime to do shell script "date +%H%M%S"
	do shell script ("screencapture -i -w " & dFolder & tTime & ".png")
	delay 2 --alter to suit
end repeat

Sorry Budgie, just noticed your reply.
Thank you.

So, to clarify,
screencapture -i -w
is the code that does a screenshot of just the front window, right?

And going even deeper,
Is there anyway to designate just a portion of the screen, meaning to specify the screenshot in terms of screen coordinates?

(I need to frequently snap a certain block of the screen, but 30 or 40 times in a row, so a single keyboard s-cut would be handy)

Hello.

Here is a free fancy little taker of predefned screenshots among other things.

I leave the testing of the utility to you. :slight_smile:

give this a spin, you will need to alter the area of screen to be captured

set DestFolder to "~/Desktop/screencapture/"
do shell script ("mkdir -p " & DestFolder)
set RepeatAmount to text returned of (display dialog "How many times to repeat capture?" default answer "2")
repeat RepeatAmount times -- alter repeat to suit
	set TheTime to do shell script "date +%H%M%S"
	set DocTitle to TheTime & ".png"
	set Captureto to "/Users/AutoFetishist/Desktop/screencapture/" & DocTitle -- change user name
	set GetPath to quoted form of Captureto
	do shell script ("screencapture -t  png -x " & GetPath)
	do shell script "sips -c 300 600 " & GetPath & " --out " & GetPath --change to get the area of screen required
	delay 2 --alter to suit
end repeat

yes

just mucking around, added some code to number the file from 1 to what ever amount the repeat amount is
and a dialog to tell you when your captures a complete, finding this useful to me also.

set DestFolder to "~/Desktop/screencapture/"
do shell script ("mkdir -p " & DestFolder)
set RepeatAmount to text returned of (display dialog "How many times to repeat capture?" default answer "2")
set NumberOfShot to 0
repeat RepeatAmount times
	set NumberOfShot to NumberOfShot + 1
	set TheTime to do shell script "date +%H%M%S"
	set DocTitle to NumberOfShot & space & TheTime & ".png"
	set Captureto to "/Users/AutoFetishist/Desktop/screencapture/" & DocTitle -- change user name
	set GetPath to quoted form of Captureto
	do shell script ("screencapture -t png -x " & GetPath)
	do shell script "sips -c 300 600 " & GetPath & " --out " & GetPath --change to get the area of screen required
	--delay 0.3 --uncomment to use
end repeat
activate
display dialog "All Done" giving up after 3

Did the trick. Almost more than I could have asked for.
:wink:
I love raw freeware that (almost) no one’s ever heard of.

Many thanks, McUsr.

Hello

I am glad it works for you. :slight_smile: