Help Downloading Statements

I like that idea. With a mischievous bent one could have a lot of fun pranking family members.

Oh man, that brought back a chilling memory. Can't remember the details - it was a long time ago. But somehow I had set up a recorded voice to say something late at night, to prank someone who was going to be on my computer.

They ended up coming at a different time, and I forgot all about it. Until I was home alone late one night, and I had the volume turned up... Hoo boy, did that scare the daylights out of me. Serves me right!

Hey Bruce,

I'm not clear on what you're doing, but here's a few tidbits:

tell application "Mail"
  set selectedMessageList to selection
  
  repeat with theMessage in selectedMessageList
    set msgSubject to subject of theMessage
    set msgSender to sender of theMessage
    
    if msgSubject contains "something" or msgSender contains "something else" then
      # Do Something...
    end if
    
  end repeat
  
end tell

-Chris

First of all thank you Chris. I think I have figured 95% of my macro out. It seems the best place to begin is with an Apple Mail Inbox rule instead of an AppleScript. This way no more computer resources are used than necessary. In my case I created a mail rule that will launch when the email is from: "notice@blucurrent.org" and
the subject is: “Your new eStatement is ready!”. This rule ends by executing an AppleScript: KMBCS.

This is the KMBCS Apple Script I created:

tell application “System Events” to keystroke "kmbcs"
delay (random number from 0.5 to 5)
end
beep 2

this macro just performs the key presses to launch my KM macro to download my statement from a specific credit union.

For any other members of this forum who are newbies like me you can use this script. Lust copy and paste into the Script Editor changing the kmbcs in quotes to whatever keypresses you want. This will allow you to do what I did by creating an Apple Mail Inbox rule to launch an Apple Script to in turn launch a KM Macro. One more thing I had to move the script to ~Library/Application Scripts/com.apple.mail/. Once this is done it will become a ‘linkable’ script in Apple Mail.

The problem now seems to be with either this particular credit union’s website, my ISP and/or my use of the “Wait for Safari to Finish Loading”. The best solution would seem to be for KM to halt until a page has loaded completely instead of waiting for a specified period of time. I looked at “How to tell if Safari has finished loading a web page” in this forum but I do not yet have enough knowledge to figure how if it contained a solution for my situation and if so how exactly to implement it.

As I think about the big picture for those of us who want to download statements and the time we put into trying to construct complete download macros, I have considered that maybe a less complete download macro is okay.

Consider that the companies we download statements from and especially the large ones like major credit card issuers, insurance companies and banks have an obligation to protect our data from the ‘bad guys’. I would expect that this situation is similar to the back and forth between the manufacturers of police radars and radar detectors. I can see putting in a lot of time to create a complete download macro only to have a company change some part of the ‘equation’ in an effort to increase security with the result that my macro would fail. For some of my statements I am thinking of modifying my macros to get me 80% of the way there with a popup message that will tell me to download my xyz statement. Where I think my time might be better spent is on an AppleScript that could be launched when I receive an email notifying me that my statement is ready for download. This AppleScript would have a feature that could ask me if I would like to download my statement now or would you like to be reminded at a later time. A really nice feature if it is possible would enable me to select the later time, either in minutes, hours or days.

Hey Bruce,

Don't send keystrokes to Keyboard Maestro with System Events.

Call the macro directly:

tell application "Keyboard Maestro Engine"
  do script "Generic-Test 01"
end tell

You can use the macro name or its UUID.

-Chris

Chris,

Thank you again for all of your help and the really nice AppleScript code. I like your concision in coding compared to some examples I have seen online. You also have a great way of explaining things which in turn helps me to learn AppleScript more quickly and easily. I am going to organize my coding notes with sections for AppleScript, Java, Keyboard Maestro, etc. probably in a Circus Ponies Notebook unless I find a better alternative.

I am reading a nice beginner’s book on AppleScript when I need to take a break from work as well as the Keyboard Maestro Manual. The book on AppleScript which is free in the iBooks store is titled, The Basics of Apple Script by Nayan Seth who was pursuing a MS in Computer Science at Arizona State University.

@DanThomas - To tell you the truth I hadn’t even looked into it yet but it’s so easy I think I need to go in and add it right this minute. :slight_smile:

Absolutely. It's also a good idea to do things to give you a heads up that the rules are running because think of all the times you launch mail and start working on something. I have discovered it's a good idea to know the script has fired off because I actually caused a script to cancel once. There was also getting over the shock of realizing that your computer just did something and you don't know why. You can add a tell block for announcing that the script has fired or you can add speaking steps in Keyboard Maestro. It's your choice.

I put in a speak text action as the first step in Keyboard Maestro which announces which bank statement script is initiating. It might actually be better to put it in a tell block in AppleScript since that's the first script to run. I suppose I should test it but I am less competent with AppleScript right now and find focusing on one thing at a time is better for my learning style.

Also I don't do rule running sessions I just let the statements download as the emails come in. I suppose I could consolidate some mail rules into Automation sessions and just let a bunch of Automated tasks run but I think it's better to let macros do what they do while I am watching so I can monitor things in the cases of email. There are other situations where letting something run while you grab a coffee is a better idea. Such as making thumbnails of 300 photos or situations like that. The macros that deal with statements are really in place (in my case) because the can do it so much more quickly.

I wonder if anyone else has some additional thoughts on this, one way or another?

Thank you for the feedback Tunes. I have pretty much given up on a complete statement download macro using KM. I have an Apple Mail inbox rule to notify me that a statement has arrived. I the login into the appropriate website and download the my bank, credit unions, AT&T wireless, State Farm, etc. statement. I have a Hazel function that renames these statements in the format of year-month followed by that statement name. For example, “2016-06 State Farm Statement”. That statement stays on my desktop until I reconcile the related account at which point I drag it into a folder named Hazel on my Desktop which in turn has a rule to move it into the appropriate statements folder. The issue I was having with KM was getting it recognize the latest statement on the company’s web-site and then to download it.

I like your suggestion of a speak text action. I want to do more with Apple Script but my life is way too busy currently. I have a love hate relationship with Apple Mail and am anxious to see MailMate 2 when it is released. In El Capitan Apple removed the ability to have what I will call a complex rule, i.e., a rule that has both “All” and “Any” conditions. Right now I have ~2,800 emails in my top level Inbox in part because of merchants who seem to think that I have nothing to do but read emails from them. A few merchants send me multiple email a day. My numerous Apple Mail Inbox rules do not appear to be working the way they are supposed to. In previous Apple Mail releases I could have a rule that for example would say if I receive an email from “Any” of these emails addresses “And” it has been more than x days since the email was received “Flag” and “Move” the email.

I did not think that I would save as much time getting some of these KM rules to work as I would spend using my current method. I am also thinking that banks, insurance companies, utilities, credit card companies, etc. may move towards more standardized electronic statements and web storage for this very purpose and away from JavaScript. BernSH sent me a linkin this thread about a company that offers to download your statements and email them to you as a service. I think this kind of service will grow and put pressure on companies for more statement standardization online probably with .PDF being the standard format.

BernSh I just wanted to say thank you for recommending filethis.com. Thanks again.

Very gratifying to get to contribute. Thanks for the opening :wink: