Move selection to next message in Mail

Hello
I decided that the down-arrow in Mail, to go to the next message, was too finicky on a MacBook, and so went to find an Applescript to do it, so that I could bind the F-key to it. I did find one which went part of the way (sorry, I can’t find the original post). I have now modified that to deal with

  • no selection
  • selection at end
  • multiple selection.
    However it falls over with threads. I find I am out of my depth here.

-- Move the highlight to the next message in the active window.
-- PROBLEM: Does not work with threads.
tell application "Mail"
	if selection is not {} then
		set s to last item of (get selection)
		set selMailbox to mailbox of s
		if id of message after s exists then
			set nextMessage to id of message after s
			set selected messages of first message viewer to {first message of selMailbox whose id is nextMessage}
		end if
	end if
end tell

I have since found the submission by McUsr in the Code Exchange forum, however that one doesn’t handle threads either. Please, I am looking for a solution, plus improvements to the above code.
Thanks
Greg

Hello!

If I were you, I’d either use KeyRemap4Macbook, and remap one of the Fn keys to arrow-down.

Or I’d make a script in Quicksilver or similar, which is to work when mail.app is active, that send the keypress arrow down to mail, this script being triggered by a fn-key.


tell application "System Events"
	tell application process id "com.apple.mail" to key code 125
end tell

Thanks, that did occur to me, and would be a more robust solution I imagine. I have however made a serious effort in the past with Quicksilver but found it too flaky and time-consuming. And done the whole Quickkeyes thing. (Is that what it is called?) I would rather not have these extra layers installed when the functionality can be achieved in the existing OS.

Also it would be interesting to solve the problem, as an exercise.
Cheers

*Quicksilver has been quite stable for a while now!

And before you pursue, take a look at this