When calling screencapture in terminal

the command responded as expected, and copied the image to the clipboard.

When calling Screencapture from Applescript via “do shell script”

do shell script "screencapture -ci"

the command responded with a strange rectangular tan block and without any screen capture in the clipboard.

Other failed solution attempts included

  1. Changing the screencapture destination to a file
  2. Preceding the shell script command with “/usr/sbin/”, as in
do shell script "/usr/sbin/screencapture -ci"

Does anyone have a solution to this screencapture conundrum?

I test your script in Script Editor and it does work… (make selection)
I have public.png and public.tiff in my clipboard

Also did:
applet (stay open) (WORKS)
terminal do script (WORKS)

I use Mojave… so I’m not sure why it doesn’t work for you.

Maybe you didn’t understand what the option -i does.

I am equally flummoxed as to any reason for the failure of my applescript invoked screencapture. I am comfortable with the screencapture shell command as I have successfully employed it, via terminal. I have also attempted to disable screen capture’s shadow, so that now in addition to my prior failed fixes, my list of failed attempts now includes:

  1. disabling screencapture’s shadow.

Screencapture defaults invoked by

do shell script "defaults read"

now returns

Possible thoughts on resolving this dilemma:
A. Complications to applescript calling a shell script
B. Complications that produce a rectangular tan box rather than any image in screencapture
C. Underlying preferences that Applescript calls when copying an image, that precede screen capture’s execution

Thanks for your help, and I look forward to any further insights on overcoming this script barrier.

Browser: Safari 605.1.15
Operating System: macOS 10.14

Compare yours with mine, you have target = file and I use target = clipboard

Here is my preference

“disable-shadow” = 0;
“include-date” = 1;
“last-messagetrace-stamp” = “633802172.002259”;
“last-selection” = {
Height = 135;
Width = 177;
X = 645;
Y = 455;
“last-selection-display” = 0;
“save-selections” = 0;
showsCursor = 1;
style = window;
target = clipboard;
type = png;
video = 0;

I have researched this problem, a little further. I now note that my screencapture command works:
• when called in Terminal
• when called by keyboard command command + shift +4 in any application
• when called in Script Editor

but returns no copied image but only a tan rectangle, whose size appears to match the size of the mouse coordinates, employed when the screencapture command was called.

How might a tan rectangle with mouse coordinates be trigged by something in Applescript when run in Script Debugger?

Depending on the version of macOS, you should be prompted to give Script Debugger access to Screen Recording in preferences the first time you try.

Thank you, Shane, your solution resolved my problem.