Advertisement
Guest User

Untitled

a guest
Dec 17th, 2016
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. tell application "Mail"
  2.     try
  3.         if first window is window of front message viewer then
  4.             my messageViewer()
  5.         else
  6.             my regularmessage()
  7.         end if
  8.     on error theError
  9.         my regularmessage()
  10.     end try
  11. end tell
  12.  
  13. on messageViewer()
  14.     tell application "System Events" to tell process "Mail"
  15.         set mainWindow to the first window
  16.         set rootSplitter to the first splitter group of the mainWindow
  17.         set firstSplitter to the last splitter group of the rootSplitter
  18.         set scrollArea to the last scroll area of the firstSplitter
  19.         set scrollGroup to the first group of the scrollArea
  20.        
  21.         if number of groups of the scrollGroup is greater than 1 then
  22.             set maybeRemoteContentGroup to the first group of the scrollGroup
  23.            
  24.             if number of buttons of the maybeRemoteContentGroup is greater than or equal to 1 then
  25.                 set maybeRemoteContentButton to the last button of the maybeRemoteContentGroup
  26.                 if name of the maybeRemoteContentButton contains "load remote content" then
  27.                     click the maybeRemoteContentButton
  28.                 else
  29.                     name of the maybeRemoteContentButton
  30.                 end if
  31.             else
  32.                 UI elements of maybeRemoteContentGroup
  33.             end if
  34.         else
  35.             UI elements of the scrollGroup
  36.         end if
  37.     end tell
  38. end messageViewer
  39.  
  40. on regularmessage()
  41.     tell application "System Events" to tell process "Mail"
  42.         set mainWindow to the first window
  43.         set mainScrollGroup to the first scroll area of the mainWindow
  44.         set everyMessage to every group of the mainScrollGroup
  45.        
  46.         log (number of everyMessage)
  47.         repeat with currentMessage in everyMessage
  48.             set loadRemoteContentButton to the first button of the first group in the currentMessage
  49.             click the loadRemoteContentButton
  50.         end repeat
  51.     end tell
  52. end regularmessage
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement