Screenshot while Mail is active

Hello

I have a large script driving Mail in which I face an unexpected behavior.
To track it I wish to force the script to take a screenshot of the entire screen.

When I do that by hand I press 3 + command + shift

So I assumed that the code below woul do the job.

tell application "System Events" to tell process "Mail"
	set frontmost to true
	keystroke "3" using {command down, shift down} -- supposed to take a screeshot of the entire screen
end tell

What am I doing wrong ?

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 2 avril 2020 19:35:06

I don’t know what was wrong but I got a working code:

set dest to (path to desktop as text) & "Screenshots:"
tell (current date) to set stamp to (((its year) * 10000 + (its month) * 100 + (its day)) as text) & "_" & text 2 thru -1 of ((1000000 + (its hours) * 10000 + (its minutes) * 100 + (its seconds)) as text)
set qpPath to quoted form of (POSIX path of (dest & stamp & ".jpg"))
set _image to do shell script ("screencapture -t jpg -x " & qpPath)

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 2 avril 2020 19:49:31

Wrong hope.

The code really take a screenshot but the rectangle where is a dialog display info about what is wrong is blank.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 2 avril 2020 21:13:53

You should use not “3”, but what is above the “3” on the keyboard. And that is when we press SHIFT, we go to upper latters. That is, you should use '#".


tell application "System Events" to tell process "Mail"
	set frontmost to true
	keystroke "#" using {command down, shift down} -- supposed, and takes a screenshot of the entire screen
end tell

Thanks to try to help but here in France, the second char on key “3” isn’t # but the character quote.

keystroke quote using {command down, shift down}

does the trick.

As “3” is get by pressing the key “3” with the shift key,
I had tried with : keystroke quote using {command down} which failed.

It’s one of the numerous shortcuts whose behavior is cumbersome.

In an other thread you posted an other one: keystroke “,” using {command down}
It works with AZERTY layout but I’m not sure that it works with QWERTY ones.

I faced the same problem recently with keystroke “'” using {command down} which works with AZERTY layout but may be replaced by keystroke “4” using {command down} for QWERTY ones.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 3 avril 2020 10:29:12