The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   Applications (http://hintsforums.macworld.com/forumdisplay.php?f=5)
-   -   Applescript - is this doable (http://hintsforums.macworld.com/showthread.php?t=24137)

winwintoo 05-24-2004 03:11 PM

Applescript - is this doable
 
Mom is old, her eyes are bad, her memory ain't what it used to be but she loves receiving and sending email. As simple as mail.app is, it is still confusing for her because she has tunnel vision in her one good eye.

She sees fine as long as she can clue into what she's looking for.

What I would like to do:

Set up an F-key for each of us that she can just click on to bring up ONLY the mail that person has sent her with unread differentiated from read by color, and a button she can push to read the mail and another button to write mail with the address already in it so she only needs to write the subject.

I've looked at the new mail script that's in the script menu of mail, but I'm new to Applescript and don't know if it's doable to hide/show based on a search which is basically what I want to do and also add my own buttons to the interface or capture the events generated by the mail.app buttons.

I'm not new to programming and don't mind the heavy lifting, but I need to be pointed in the right direction.

We will be installing TimBukTu this week so we can go in while she's napping and reset things when she gets a thousand windows open and can't find anything, but this mail is driving us nuts - it's too complex for an old lady with a grade 3 education.

Thanks, Margaret

AHunter3 05-24-2004 04:19 PM

Seems like it would be easier to do in Eudora. Wouldn't need AppleScript, just give each of the kids their dedicated mailboxes, with filters to sort incoming mail to the right mailbox. If you need single-key jumping to the correct mailbox, name them

"1. Joe"
"2. Susannah"

etc.

She opens Eudora, types 2 hits return, she's in Susannah's mail to her. Hit return on any one of them and hit Command-R and she's emailing Susan.

At worst you might want a script to bring the Mailboxes window to the front.

schneb 05-24-2004 05:06 PM

Quote:

Originally Posted by winwintoo
Set up an F-key for each of us that she can just click on to bring up ONLY the mail that person has sent her with unread differentiated from read by color, and a button she can push to read the mail and another button to write mail with the address already in it so she only needs to write the subject.

In the mean time, you may wish to setup up various folder (OK Apple, Mailboxes) with each siblings names. Create a filter to send the appropriately addressed mail to the various folders. As she clicks on the folder for, say Margaret, she will only see the email from you. You can even make the filter change the color if you like.

It's not your solution, but it is a start.

Write Apple and let them know that Mail is not providing enough control in how it displays for those of limited eyesight. I'm sure they could make some enhancements.

winwintoo 05-24-2004 06:15 PM

We tried having the individual folders - which works for me and I thought it would be a great solution for her too, but even though there were dozens of emails sitting there from each of us, she kept complaining that she wasn't getting any mail.

She's old, can barely move the mouse, I think she actually only sees about the size of a silver dollar at once, and everything around it is blurry so having to adjust her creaky old neck to point her eye to all those folders was too much for her. Imagine reading a 15" monitor through a 1" tube - not an easy job.

Anything that requires a combination of keystrokes is beyond her, especially if she would have to remember a number of different combinations to accomplish different tasks. That's why the F-keys would work perfect, they're not used much and we put big stickers on them for her.

We just got her a new iMac so the screen would be brighter and she likes that, but now the screen is so big and too much real estate to cover. We had the F-keys on the old iMac (OS9) programmed to jump from program to program and she liked that and managed well with it.

It's too bad. She's frail and falling apart physically, but her mind is still very bright, just slow and this is her first exposure to technology. When we're there with her she catches on real fast and asks good questions, but then the next day she forgets.

There's a huge untapped market out there in the older generation. Mom has 6 kids and umpteen grandkids who've all done very well and we can afford whatever it takes for Grandma to have a wonderful time on the computer, but there are few applications geared for them.

I'll quit preaching now.

Thanks, Margaret

bramley 05-24-2004 06:35 PM

OK

If you can do what the guys above suggested to sort the incoming mail into a series of mailboxes, one for each sender, then I think the script below will allow your mum to display just the messages from one of you.

Code:

property desired_mailbox : "Name of Sender's Mailbox goes here"

tell application "Mail"
        activate
        set themailbox to mailbox desired_mailbox as list
        tell front message viewer
                set selected mailboxes to themailbox
                set sort column to message status column
        end tell
end tell

For each sender, copy the above script into /Library/Scripts/Mail Scripts, giving each one a unique name. You will need to alter the part of each script that reads "Name of Sender's Mailbox goes here" to be the name of the mailbox in Mail. The scripts will now appear in Mail.app's script folder.

Then open System Preferences, select "Keyboard and Mouse" and add a keyboard shortcut for Mail.app, for each sender, typing in the name for each script in the script menu. Assign each script to a F-key.

This should give a display of messages for each sender, with unread messages at the bottom. Unfortunately, my script doesn't change colours of messages so that your mum can differentiate between unread and read but I'll give it some more thought.

winwintoo 05-24-2004 07:33 PM

Quote:

Originally Posted by bramley
OK
For each sender, copy the above script into /Library/Scripts/Mail Scripts, giving each one a unique name. You will need to alter the part of each script that reads "Name of Sender's Mailbox goes here" to be the name of the mailbox in Mail. The scripts will now appear in Mail.app's script folder.

Then open System Preferences, select "Keyboard and Mouse" and add a keyboard shortcut for Mail.app, for each sender, typing in the name for each script in the script menu. Assign each script to a F-key.

This should give a display of messages for each sender, with unread messages at the bottom. Unfortunately, my script doesn't change colours of messages so that your mum can differentiate between unread and read but I'll give it some more thought.

That gives me a good start, I'll start with that and go from there. Thanks a lot.

Margaret

stetner 05-24-2004 11:56 PM

Have you tried enabling 'ZOOM' under the 'universal access' prefs pane? It may be too complicated for her to use, but you never know....

winwintoo 05-25-2004 08:54 AM

Quote:

Originally Posted by stetner
Have you tried enabling 'ZOOM' under the 'universal access' prefs pane? It may be too complicated for her to use, but you never know....

I played with that a bit, but the problem with her eye (she only has sight in one eye therefore no depth perception) is that she has tunnel vision so it's like looking at everything through a long tube. She sees clearly a point about 2 inches square and the rest fades and grays out. To see anything else she needs to move her head and refocus her eye. We've increased the font size and the screen is crisp so what she's actually looking at is crystal clear.

The problem on the screen is that things move around whereas the keyboard remains the same from one use to the next.

I'm thinking of looking into Netopia's kiosk software. See if that would do the job.

Thanks for the suggestions, keep them coming. Every suggestions adds significantly to the body of knowledge and combined will come up with a killer solution.

Margaret

hayne 05-25-2004 09:39 AM

You might want to look into having Apple's text-to-speech read the mail messages. There have been some articles on the main macosxhints site showing how to use AppleScript to get Mail.app and Entourage to read out the subject line and sender when a new mail arrives. But you could in the same way provide a menu item to read all (unread) mail from a given sender.

And you might consider using AppleScript Studio (part of Apple's free developer tools) to create a user-interface for those AppleScripts you are writing. You could make a complete stand-alone app that would be customized for your Mom's needs.

winwintoo 05-25-2004 09:49 AM

Quote:

Originally Posted by hayne

And you might consider using AppleScript Studio (part of Apple's free developer tools) to create a user-interface for those AppleScripts you are writing. You could make a complete stand-alone app that would be customized for your Mom's needs.

Your suggestion is ideal - and my heart is willing, by my mind is weak :o :o

We've got TimBukTu installed on her computer now, but for some reason I can't connect to it so once we get that working things will hopefully settle down and maybe we won't have a problem in the short term, but as Mom ages, it would be nice to have a plan "b" for keeping things simple in the future. AND I think your suggestion has merit as an application that others can use as well.

Thank you, Margaret

bramley 05-25-2004 02:47 PM

This first script is a replacement for the previous one I did. This one sorts by date sent which is probably more use.

Code:

property desired_mailbox : "Sender mailbox goes here"

tell application "Mail"
        activate
        set themailbox to mailbox desired_mailbox as list
        tell front message viewer
                set mailbox list visible to false
                set selected mailboxes to themailbox
                set sort column to date sent column
                set selected messages to {}
        end tell
end tell

The second script allows all unread messages to be read sequentially from the currently displayed message viewer which is set by the above script. Note it alters colours as it works. The colours could be set by the rules suggested earlier in scheb's post.

Code:

tell application "Mail"
        activate
        if (count of windows) > 2 then
                tell application "System Events"
                        tell process "Mail"
                                keystroke "w" using command down
                        end tell
                end tell
        end if
        tell front message viewer
                if exists (first message whose read status is false) then
                        set current_message to first message whose read status is false
                        set background color of current_message to none
                        open current_message
                end if
        end tell
end tell

Finally, your family sounds like a big one. Are there enough F-keys?! Slight variation on Hayne's idea might be to use a menu with all of your first names on it. The third script gives you the idea. You can use the arrow keys to scroll through the names, and the enter key to select a name which would identify the right mailbox for my first script. You can of course have the menu script keyed to a F-key.

Code:

set response to choose from list {"grandson1", "grandson2", "grandson 3"}

schneb 05-25-2004 07:09 PM

Since I do not know AppleScript (just can't get a handle on it) all I can offer is a little direction. I wish Apple had a couple more conditions in their rule definitions. However, I did see a rule that says "Run Apple Script" so that if you set it where new messages will run a script to label the mail somehow, that might simplify things.

winwintoo 05-25-2004 07:49 PM

Quote:

Originally Posted by schneb
Since I do not know AppleScript (just can't get a handle on it) all I can offer is a little direction. I wish Apple had a couple more conditions in their rule definitions. However, I did see a rule that says "Run Apple Script" so that if you set it where new messages will run a script to label the mail somehow, that might simplify things.

I did notice that - I'm wondering if it's new since I don't remember seeing it before. That ability along with the script help and suggestions that Bramley has given me is a step in the right direction.

Hopefully this thread will turn into a useful reference for the future for the next person faced with similar problems.

Take care, Margaret

dzurn 05-26-2004 01:06 AM

you might also try decreasing the screen resolution. I'm able to change the size of my 19" monitor to 640x480, which is huge! That blows everything up, and the Mac will make everything fit.

At least she can see what she has got.

Best wishes to your mom, you are very thoughtful!

winwintoo 05-26-2004 08:28 AM

Quote:

Originally Posted by dzurn
you might also try decreasing the screen resolution. I'm able to change the size of my 19" monitor to 640x480, which is huge! That blows everything up, and the Mac will make everything fit.

At least she can see what she has got.

Best wishes to your mom, you are very thoughtful!

Another good suggestion Dzurn, will give that a try.

The TimBukTu is working out well. One of the problems is that the techno jargon that comes so easily to us is like a foreign language to Mom and she was finding it hard explaining what she was having trouble with. We finally installed TimBukTu and it's working out wonderfully. We're able to watch what Mom does and then explain what she could do differently and she is ecstatic!!

Take care, Margaret

whom444 05-27-2004 09:16 PM

If sight is a problem, explore SpeechRecognitionServer and Text-to-Speech.
Below is a code snippet to get you started.

Code:

set boxes to {"Bill", "Sally"}
set myPrompt to "What mailbox do you want " & boxes & "?"
tell application "SpeechRecognitionServer"
        set theResult to (listen for boxes with prompt myPrompt displaying boxes giving up after 15)
        say "You have chosen " & theResult
end tell
tell application "Mail"
        activate
       
        try
                set selected mailboxes of the front message viewer to {mailbox theResult of application "Mail"}
        on error the error_message number the error_number
                -- don't display error message if the user canceled a dialog within the [try] and [on error] lines above
                if the error_number is not -128 then
                        set the error_text to "Error: " & the error_number & ". " & the error_message
                        display dialog the error_text buttons {"Cancel"} default button 1
                else
                        error number -128
                end if
        end try
end tell

see this link to see more explanation about speech recognition.

Where you see "Bill" and "Sally" above, need to be changed to mailbox folders in the "On My Mac" section of the mailboxes drawer. Also, you would have needed to previously set up these folders for automatic sorting by name.

Hope it helps (I was successful on a small test on my laptop)

thayward 08-30-2004 08:03 PM

How do I add a recipient to Entourage mail message
 
I've written the following applescript that checks for valid recipients, then creates a new message with only valid recipients. (This is strickly for a work project just to learn applescript). Anyways, here's my code: Please take a look at the UPPER CASE COMMENT

tell application "Microsoft Entourage"

set draftMessages to every message in the drafts folder

set validRecipients to {"xxx@somewhere.net", "yyy@somewhere.net"}

repeat with theMsg in draftMessages

copy the recipients of theMsg to msgRecipients --msgRecipients is a list of records
log msgRecipients
log class of msgRecipients

repeat with aRecipient in msgRecipients

set theSubject to subject of theMsg
set theContent to content of theMsg
set theStorage to storage of theMsg
set theAccount to account of theMsg
set theSource to source of theMsg

set newMsg to make new outgoing message with properties ¬
{subject:theSubject, content:theContent, storage:theStorage, account:theAccount, source:theSource} ¬


copy the address of aRecipient to theRecipient
log theRecipient

if validRecipients contains (address of theRecipient) then
log "Valid Recipient"

--WHAT I REALLY WANT TO DO HERE IS ADD THE VALID RECIPIENT TO THE END OF THE LIST OF RECIPIENT RECORDS

tell newMsg
{recipient:{recipient type:to recipient, address:theRecipient, display name:""} ¬
}
end tell

else
log "Invalid Recipient"
end if

end repeat
end repeat
end tell

whom444 08-30-2004 08:18 PM

First of all, I would try to edit your post to take out real email addresses. Computer programs can scour the web for email addresses and pound you with spam. Change those things to something like XXX@somewhere.com

Gfx 08-30-2004 08:47 PM

I agree with whom444 as it might be worth the effort to explore SpeechRecognitionServer and Text-to-Speech.

I am not an expert with AppleScript but I think one could make a script (or better an AppleScript Studio application) that on opening will check the different mailboxes, tell which ones have new mails, ask if the person want to read the first mail, wait for a simple answer (yes or no), read it or not, if the mail as been read, ask if the person want to delete it and go on the next mail.

Well... this isn't quite complete but you get the point. I know that this should be quite doable but might take a little while to get all the things done (at least for me). If the reading is unsuitable, it is also possible to make Mail to open email, resize and reposition the window and "wait" for it to be closed to get to th next email.

If I had the knowledge and if Fed Ex had not lost my G5 Dual 2.5 GHz, I would certainly give this a try. Maybe someone with more knowledge on AppleScripting and more ressources might be interested.

Good luck anyway... :)

whom444 08-30-2004 09:50 PM

Quote:

Originally Posted by thayward
I've written the following applescript that checks for valid recipients, then creates a new message with only valid recipients. (This is strickly for a work project just to learn applescript). Anyways, here's my code: Please take a look at the UPPER CASE COMMENT

This should probably be a new thread, but here is a quick stab. If this doesn't help you, try starting a new thread.

The computer I'm working on doesn't have Entourage right now, but something similar may work:
Code:

tell application "Mail"
        activate
        set addressees to {}
        set newMsg to make new outgoing message with properties {subject:"hi", content:"hi"}
        set addressees to {"billATspam.net", "sallyATspam.net"}
        copy "tomATspam.net" to the end of addressees
       
        tell newMsg
                set visible to true
                repeat with eachAddr in addressees
                        make new recipient at end of to recipients with properties {name:eachAddr, address:eachAddr}
                end repeat
        end tell
        addressees
end tell


Clytie 08-31-2004 05:14 AM

Mail does have "run Applescript" in the list of available actions in Prefs -> Rules (a.k.a. Filters). You can also add headers to the list available, so it would be quite easy to specify custom headers in different types of incoming mail if you wanted to be able to control more choices than just "it's from X".

Thankyou to winwintoo for bringing up the access question again: I've been very ill and disabled for years now, and among user groups for people who are dealing with multiple disabilities, user interface is a huge issue: even Mail can defeat people who need to be able to access such lists/sites. Something very simple, to reduce the amount of info on the screen, and make the main choices very big and very clear and very easy to input, would make things much easier for people for whom a computer is truly a window on the world.

Does anyone know if any developers are working on ways to simplify computer use for ill/disabled people? I would appreciate any info/links.

Your mother sounds like a wonderful person, winwintoo, I respect her greatly for her willingness to take on so much new information, and her evident zest for life. :)

from Clytie, for whom everything is fogging out again now


All times are GMT -5. The time now is 01:32 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.