Le 13/12/2014 à 00:08, Brian Christmas < email@hidden> a écrit :
G’day scripters
Yosemites ‘Mail’ has been cut off at the knees.
When trying to access the ‘File/Save Attachments..’ menu from a script opened message, the menu item remains greyed out.
No amount of GUI clicking on the interface that I’ve tried has worked.
I really, really need that menu item activated, so I’m hoping that wiser heads than mine can advise me of a way (yes. it’s you lot I’m referring to).
I’ve tried the following (which I’ve also posted on the ‘Mail’ forum), but Mail no longer responds to clicks, it seems.
Any remedies, please?
Regards
Santa
set SaveAttachmentsMenu to true tell application "Mail" activate set WindowCount to count of windows open item 1 of messages of mailbox "* items to store" # drafts mailbox set x to 0 repeat # wait until the message is really open. tell current application to delay 0.1 set x to x + 1 if x > 40 then exit repeat if (count of windows) > WindowCount then exit repeat end repeat tell application "System Events" to tell process "Mail" tell current application to delay 1 try select scroll area 1 of window 1 click end try try tell scroll area 1 of window 1 set {xPosition, yPosition} to position set {xSize, ySize} to size end tell -- modify offsets if hot spot is not centered: click at {xPosition + (xSize div 2), yPosition + (ySize div 2)} display dialog xPosition & tab & yPosition as text on error errmsg display dialog errmsg end try tell current application to delay 0.2 if exists menu item "Save Attachments…" of menu 1 of menu bar item "File" of menu bar 1 then keystroke "a" using command down if not enabled of menu item "Save Attachments…" of menu 1 of menu bar item "File" of menu bar 1 then say"attachments disabled" click menu item "Select All" of menu 1 of menu bar item "Edit" of menu bar 1 set x to 0 try click menu item "Save Attachments…" of menu 1 of menu bar item "File" of menu bar 1 end try repeat until exists sheet 1 of window 1 tell current application to delay 0.1 set x to x + 1 if x = 40 then set SaveAttachmentsMenu to false exit repeat end if end repeat end if end tell end tell SaveAttachmentsMenu _______________________________________________
Hello Brian
To test your script, I had to made some changes because I use the system in French. I did that the quick and dirty way. When it was done, I discover that you failed to define the variable SaveAttachmentsMenu when the menu item is enabled. So, I added an instruction to fill the gap. After that I discovered that although the menu item was enabled, the script said that it was not.
I decided to disable the piece of code displaying a position in a dialog. So, I discovered that when this code is disabled the menuItem SaveAttachments… is correctly reported as enabled while when the code is executed, the menu item is reported as disabled although it IS enabled.
My understanding is that after the dialog, it's no longer the process Mail which is frontmost so I edited the script one more time to force the process Mail to be at front. Bingo, with this change it works.
set theMailBox to "forBrian" # "* items to store" # drafts mailbox set FileMenu to 3 set EditMenu to 4 set SelectAll to "Tout sélectionner" # "Select All"
set SaveAttachmentsMenu to true tell application "Mail" activate set WindowCount to count of windows open item 1 of messages of mailbox theMailBox set x to 0 repeat # wait until the message is really open. tell current application to delay 0.1 set x to x + 1 if x > 40 then exit repeat if (count of windows) > WindowCount then exit repeat end repeat tell application "System Events" to tell process "Mail" tell current application to delay 1 try select scroll area 1 of window 1 click end try
try tell scroll area 1 of window 1 set {xPosition, yPosition} to position set {xSize, ySize} to size end tell -- modify offsets if hot spot is not centered: click at {xPosition + (xSize div 2), yPosition + (ySize div 2)} display dialog (xPosition as text) & tab & yPosition --EDITED on error errmsg display dialog errmsg end try end tell # System Events…
tell current application to delay 0.2
tell application "System Events" to tell process "Mail" set frontmost to true # BRING THE PROCESS AT FRONT set mNames to name of menu items of menu 1 of menu bar item FileMenu of menu bar 1 (* (01) Nouveau message, (02) Nouvelle fenêtre de visualisation, (03) Ouvrir le Message, (04) missing value, (05) Fermer, (06) Fermer toutes les fenêtres, (07) Enregistrer, (08) Enregistrer sous…, (09) Enregistrer comme modèle…, (10) missing value, (11) Joindre des fichiers…, (12) Enregistrer les pièces jointes…, Coup d’œil sur les pièces jointes…, missing value, Importer des boîtes aux lettres…, missing value, Exporter au format PDF…, missing value, Imprimer…*)
set saveAttachmentsLoc to item 12 of mNames
set SaveAttachmentsMenu to true # MUST BE DEFINED AT LEAST ONCE ! if exists menu item saveAttachmentsLoc of menu 1 of menu bar item FileMenu of menu bar 1 then keystroke "a" using command down repeat 3 times set isEnabled to enabled of menu item saveAttachmentsLoc of menu 1 of menu bar item FileMenu of menu bar 1 log isEnabled end repeat if not isEnabled then say "attachments disabled" click menu item SelectAll of menu 1 of menu bar item EditMenu of menu bar 1
set x to 0 try click menu item saveAttachmentsLoc of menu 1 of menu bar item FileMenu of menu bar 1 end try repeat until exists sheet 1 of window 1 tell current application to delay 0.1 set x to x + 1 if x = 40 then set SaveAttachmentsMenu to false exit repeat end if end repeat end if end tell end tell SaveAttachmentsMenu
Oops, I was forgetting a question :what is the need for the Select All action ?
Yvan KOENIG (VALLAURIS, France) samedi 13 décembre 2014 11:29:16
|