Hello,
I am trying to develop (well, actually modify) a script to provide navigation in an Apple Mail mailbox.
When a message window is open, Mail does not provide a means to move to the next message without doing this little dance:
1. close message window
2. press arrow key to navigate to next message
3. press Return
These have been combined into a script (below), but it navigates to the next unread message. I want to navigate to the next message, regardless read OR unread.
Any help getting me pointed in the right direction will be gratefully appreciated.
Thanks,
This version will reiterate the selection of nested mail folders. It also offers to print, and the best I can do with threaded messages is to hand the focus back to Mail while the navigation panel is showing, so you can expand the thread. Hope it's what you want.
property x : {}
on run
my setUpLoop()
end run
on setUpLoop()
tell application "Mail"
activate
set x to {}
tell (some message viewer whose index is 1)
set eachMailBox to item 1 of (get selected mailboxes)
--say (count of eachMailBox)
my checkLoop(eachMailBox)
end tell
my MainLoop(1)
end tell
end setUpLoop
on checkLoop(eachMailBox)
tell application "Mail"
tell (some message viewer whose index is 1)
repeat with yy in messages of eachMailBox
set end of x to yy
end repeat
repeat with yy in mailboxes of eachMailBox
my checkLoop(yy)
end repeat
end tell
end tell
end checkLoop
on MainLoop(xx)
tell application "Mail"
activate
repeat
set xxx to (item xx of x)
set selected mailboxes of message viewers to mailbox of xxx
set selected messages of message viewers to xxx
tell application "Finder"
activate
display dialog "Backwards or Forwards" buttons {"Backwards", "Select this one", "Forwards"}
end tell
set b to button returned of the result
if b = "Select this one" then exit repeat
if b = "Backwards" then
set xx to xx - 1
if xx < 1 then set xx to count of x
end if
if b = "Forwards" then
set xx to xx + 1
if xx > (count of x) then set xx to 1
end if
end repeat
end tell
my WaitLoop(xx)
end MainLoop
on WaitLoop(xx)
tell application "Finder"
activate
display dialog "Resume, Print, or Cancel" buttons {"Resume", "Print", "Cancel"}
set b to button returned of the result
if b = "Resume" then my MainLoop(xx)
if b = "Print" then
tell application "Mail" to activate
tell application "System Events" to tell process "Mail" to keystroke "p" using command down
my WaitLoop(xx)
end if
end tell
end WaitLoop