• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Mail.app Message Windows
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Mail.app Message Windows


  • Subject: Mail.app Message Windows
  • From: Christopher Stone <email@hidden>
  • Date: Sun, 18 Oct 2015 23:29:16 -0500

Hey Folks,

One of the pesky issues with Mail is differentiating between mail-viewer-windows and message-windows.

Since System Events has gotten faster and more reliable I've been willing to use it more, and in this case I used it to find only message windows.

You have to have the 'Get Mail' button in your message-viewer toolbar for this to work, and I'm not taking into account any localization.

-------------------------------------------------------------------------------------------
# Written for someone on another list.
-------------------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2015/10/18 22:20
# dMod: 2015/10/18 22:39
# Appl: Mail, System Events
# Task: Close Message Windows using a Pick-List.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Mail, @System_Events
-------------------------------------------------------------------------------------------

tell application "System Events"
  tell application process "Mail"
    set winList to windows
    set messageWinNameList to {}
    repeat with i in winList
      if not (exists of button "Get Mail" of toolbar 1 of i) then
        set end of messageWinNameList to name of i
      end if
    end repeat
  end tell
end tell

-------------------------------------------------------------------------------------------

tell application "Mail"
  set closeWinList to choose from list messageWinNameList with title "MESSAGE WINDOWS" with prompt ¬
    "Choose which windows to close:" default items {item 1 of messageWinNameList} ¬
    with multiple selections allowed
  try
    repeat with i in closeWinList
      close window i
    end repeat
  end try
end tell

-------------------------------------------------------------------------------------------

Okay, playing with it this evening:

-------------------------------------------------------------------------------------------
tell application "System Events"
  tell application process "Mail"
    set winList to windows where (name of buttons of its toolbar 1) does not contain "Get Mail"
  end tell
end tell
-------------------------------------------------------------------------------------------

Still not discriminating between received and outgoing messages, but it's a start.

--
Best Regards,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: AppleScript grammar
  • Next by Date: Re: AppleScript grammar
  • Previous by thread: Re: AppleScript grammar
  • Next by thread: ApplescriptObjC
  • Index(es):
    • Date
    • Thread