Thursday, July 9, 2020

#1 2020-04-02 11:37:16 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4545

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.

Applescript:

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

Offline

 

#2 2020-04-02 11:49:54 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4545

Re: Screenshot while Mail is active

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

Applescript:

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

Offline

 

#3 2020-04-02 01:14:00 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4545

Re: Screenshot while Mail is active

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

Offline

 

#4 2020-04-02 10:03:39 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Screenshot while Mail is active

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 '#".

Applescript:


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

Last edited by KniazidisR (2020-04-02 10:09:23 pm)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#5 2020-04-03 02:38:46 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4545

Re: Screenshot while Mail is active

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

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)