do shell script "/usr/sbin/screencapture -x -t pdf -i -w " & ((quoted form of POSIX path of ((path to desktop) as string) & "apic.pdf") as string) & " &> /dev/null &"
will get screencapture to show the little camera icon and wait for a click to take a screen capture of a window. Clicking the mouse on a window will save the picture in ~/Desktop/apic.pdf (overwriting the previous picture… which is OK for now).
How can I tell screencapture to click at a position?
I’ve tried everything I can think of using the following with different names put in for “SomeProcessNameHere”, all to no avail.
tell application "System Events"
if UI elements enabled then
tell application process "SomeProcessNameHere"
click at {150, 125}
end tell
end if
end tell
Anyone have any ideas? FWIW, Snapz Pro is no help, because once it has been convinced to take a picture of an object, it stops listening to the applescript.
I’ve seen other posts about taking full screen captures and then cropping, but this won’t work in my situation, because
. the windows I want to take pictures of are not all the same size
. the application is not applescriptable, so I cannot ask it for the bounds of the window whose picture I would like.
Even bad news would be appreciated, because I’m soon going to need a bad combover.
I know this thread is old and abandoned, but I have the same problem. Did anyone ever find a solution? It seems to me that the most “recent” answer won’t work either. I think the -w option on the shell script puts the AppleScript on pause waiting for a mouse click, which would make subsequent AS commands redundant/too late.
If there was a way to follow the screencapture shell script with an inline pseudo-mouse click shell script event, that might do it; but does such a thing exist?
I’ll keep digging. If anyone has a better idea, please let me know.
(I like and need to use the -w option because it allows for capturing just a specific window, with its surrounding drop shadow–the equivalent of cmd-shift-4, spacebar before clicking. I also like the flexibility of using the shell command to include a filename and path determined within preceding AS.)
Thanks.
Yes, it’s possible, I use the following solution in one of my work projects. It’s just sample code, you will need to adjust the paths to your own requirements. Moreover it makes use of cliclick.
1. Script
ignoring application responses
tell application "AppleScript Runner"
launch
-- this second script does the clicking!
do script "/Users/martin/Desktop/click.scpt"
end tell
end ignoring
do shell script "screencapture -w /Users/martin/Desktop/test.png"
2. Script (click.scpt), called by the first script
delay 5
do shell script "/Users/martin/Desktop/cliclick d 250 250"