Help Downloading Statements

Bruce, in order to help you we need more info.

Please post the following:

  1. Your latest macro that tries to achieve your objective
  2. Identify specifically what is NOT working with this macro
  3. Screen shots of the web pages you're trying to use (IF they do NOT contain any personal or sensitive information)
  4. Any other details you think would be helpful.

Given the right information, I would be very surprised if we can't get you going, but it may very well take some trial-and-error, and definitely some patience. :smile:

P.S. One thought that may get you going now: Use 1Password to get logged in to your account completely, so that you are ready to goto the statement download page. Then adjust your KM Macro to process the site from that point.

Thank you JMichaelTX. I have been playing around with this since my post. Right now I am trying to get my Online Banking ID: filled in and "Submitted". I have removed my actual ID information for the upload to the forum but it is entered in the "field value". Previously KM was able to do this but I forgot what I did to make that work.

Here is my Macro thus far:

Here is a screen shot of the first login screen at my credit union showing the submit button.

After this screen I can use the 1Password feature to fill in my password. What I can't figure out is how to 'click' on the submit button. I would think that it should be coded into the page information in a way that KM can 'see it' and 'click on it' without recording a mouse click on it.

Okay. I have been able to get the login field to fill. Using the following. Now I just need to figure out how to activate the "Submit" button. I have removed my login ID for the upload. It seems like I should be able to use the "Click Safari Link" action but none of the choices it gave me seem to work. I have also tried the "Type a Keystroke" and used both 'Return' and 'Enter' and neither worked which I found surprising. If I press either key in Safari at the login page they work.

There is one thing that I believe is critical and has been causing me problems. Our ISP, Mediacom can be very unreliable at times. The result I think is that sometimes I have tried things that did NOT work at the time and then late they worked without issue. I will keep working with this and not post again until I am stuck at a specific step that I can articulate to the forum.

I am almost there. I also have some information that may help other novices like myself. But let me make this comment. I was a little put out that instead of being able to enter my ID and Password on one screen I have to go through 2 screens one for each item. I though more deeply about this and decided it may actually be a good safety feature put there by Jack Henry & Associates who does the websites for two of the credit unions my family uses.

This website has a lot of java on it. So instead of trying to code in a click I right clicked on, for example, the link to the location of my statements which I pasted into “Execute JavaScript in Safari”. Also because my ISP is very, very unreliable at times I have added in “Wait for Safari to Finish Loading” steps between every ‘click’.

Now here is where I need some specific advice. I am looking for a way to let KM know that my statement has downloaded completely before logging out which I hope will be another “Execute JavaScript in Safari” operation. The statement will download to the desktop with the name “download.pdf”.

If you still want to automate clicking on the Submit button, see this:

The key is determining the HTML element ID for the button.
One way to do this is to open the page in Chrome, then right-click on the Submit button, and select "Inspect".

Maybe this topic will help with the downloading complete issue:

Thank you JMichaelTX. An FYI I was able to Inspect the page in Safari but that could be because I have “Develop” enabled in Safari.

My big take away from the post was, “Learning a little JavaScript gets your foot in the door. Learning a lot will let you do magic.” So after learning some Apple Script it looks like JavaScript will be my next stop. I will read through the, information on the page “How to tell if Safari has finished loading a web page” and try to apply it to my situation. It may not be until tomorrow. I will report back to the group either way.

Hi Bruce...
I am the guy that started that other thread. Yes. You can use Safari's developer mode to get at the Javascript you need by inspecting the elements. I am going to guess that Chromes method is probably a lot more graceful than Apple's. You are on the right track. I have a hunch that your credit union uses the same solution provider for statements. (They all rely on outsourcing to 3rd party providers). Can you take a screen shot of the pages and send the URLs for the eStatements link and others? Feel free to mask any information you like. (You can use skitch to mask text and graphics in your screenshots. It's a free download. Look for the pixelation tool. (See included pic).

How I got around the password issue for one bank, was to use the Keychain. I feel secure in doing so because it's locked and I changed the keychain password so it's different from the computers login. This way if someone changes the password on the computer they would still need to use the alternate keychain password. (They would anyway).

I had the same issue you were having with eStatements. This is what worked...

I am not sure how I got it to download the statement as I have several steps. I will need to look at it and sort out which step is doing what.

Something you might try is using the "Click at Found Image" action if you have a button. You'll need to take a screenshot of the button then insert the graphic into the image container in the KM action.

You'll also need to fool with the two numbers e.g. (100,200) until you can get it to click exactly where you want. It was trial and error for me the first time I tried it then I just kept adjusting the screen axis points until I nailed the approximate center of the button. I have a credit card account that it works very well with.

Hi John,

Thank you for the suggestion. On a peripheral issue, what is going to cause me a little trouble later is that by virtue of Jack Henry & Associates managing the websites for the two credit unions my family uses the most there are issue if I access both credit unions from the same web-browser. This is okay because I have set aside Firefox for a limited number of sites where I place a high value on security.

Thanks to your post I now have a better understanding of how the 'click here' function works in KM. What I have adopted is finding the JavaScript that is launched to take me to the eStatements page and then to download the most current statement. What I will find out this month is whether the "3" in this line:
javascript:__doPostBack('ctl00$PageContent$ctl00$StatementDataGrid$ctl03$DownloadLink','')
is always the most current statement.

It may be my own ignorance but I always want my 'code' to be as concise as the best of German engineering which is why I will always try to avoid using the feature in KM and Automator where you start a program that records your actions. I think that Andy Hertzfeld was the master of this when he was programming for Apple in the days when the company was just getting started. Having said that I don't know if this 'record' feature translates movements and actions into concise code before making part of a macro or Automator program. Nevertheless I am glad it is there for those circumstances when it is the only way to get a particular task done.

Here is how I am getting my statements now:

The long load times are because of my ISP being very unreliable at times and especially when the seasons change. I initially tried working with the "Click at Found Image" action but could not get it to work. What I learned from your post, thank you again, is that I can drop an image in the 'box' for that Action, which should help when I have to use this function at a later date.

To get this Macro working more quickly I may just set a load time for the statement download instead of trying something more complicated like waiting until a file named 'document.pdf' appears on my Desktop. Then I want to go back and figure out how some people are getting their macros to launch when they receive an email from their credit union, credit card issuer, utility company, etc.

Once I have finished this I want to upload this macro after pulling out my login ID information and the specific JavaScripts my credit union uses with instructions for other users. I am a big believe in giving back to one's 'community'.

Woo hoo. Thank you JMichaelTX and John. I now have a complete though time flawed working Macro. I still want to fine tune it to do two things. First is to figure out how to pause the program until a statement has downloaded knowing that the eStatements page for my credit unions are sometimes very, very, very slow to load. I think that most of my early issues have been with my ISP and or credit union sites being very, very slow many times. The next thing as I mentioned in an earlier post is to have this macro trigger when I receive an email that my statement is ready for download. Then I can make that final edit to remove personal and credit union information and upload it as a framework for anyone to use.

1 Like

Great exercise in learning KM. Thank you!

If you simply need statements downloaded https://filethis.com does the trick. Combined with Hazel you can have them filed in folders post haste.

Don’t stop learning KM as you won’t be limited by the list of downloadable sites that filethis has.

1 Like

Hi Bruce...

I tried to set the wait times as low as possible. Then on one occasion it took an extremely long time to load the page and i decided to raise the values since the script needs run correctly every time. I think there are some other ways to deal with page loads though. I haven't finished reading the KM documentation. (Other manuals have taken precedence lately!).

If you look at the screen shot I posted above you'll see next to the image container there is a slider. This adjusts for the amount of blur of the graphic. I found in one instance I needed to move it all the way to the right to recognize the image. You'll definitely need to experiment each time you use the "Click At Found Image" action. It's one of my favorite actions because it's so easy to implement.

That's another tricky bit. Tricky because sometimes vendors change the email address they send from. (They change quite a few other things too!) I got a lot of help from Christopher Stone as well as JMichaelTX and others on pulling my scripts together.

Setting up the email part is actually the easiest part of all of this. What you have to do is setup a Mail Rule that gets triggered when the email comes in and then runs an AppleScript in Mail.app (or other mail clients) that brings Safari forward then fires the KM script. Poke around in your mail applications preferences and look for "Rules" in Mail.app or Outlook. In the rules section one of the options after filtering the email based on the rule's conditions is to run an AppleScript.

KM can help with the bit that gets entered to call the specific KM script. The AppleScript is simple and here's what it looks like:

tell application "Safari"
  if not running then run
  activate
end tell
-- ignoring application responses
tell application "Keyboard Maestro Engine"
  do script "028B720D-4B15-4A98-B289-CD87A27CEFE3"
  -- or: do script "Move or Click Mouse"
  -- or: do script "028B720D-4B15-4A98-B289-CD87A27CEFE3" with parameter "Whatever"
end tell
-- end ignoring

You have to write the first tell block but KM will write the second tell block for you and you can paste it into AppleScript then save the script. Then have your mail rule use that AppleScript. I name my AppleScripts by financial institution to keep them straight.

Next time you are in KM take a minute to look at the action where you set the keystroke to fire off the KM marco, you'll see "New Trigger" then "Or by script", click on the "Or by script" popup menu and you'll see AppleScript as an option. Once you select it, KM will generate the code to reference the KM macro you are creating. So it will always trigger that macro and no other macro.

That should get you going on having the email trigger the script. I think I need to add alerts to all my scripts and/or macros that tells me when they are running, or perhaps have AppleScript "speak text" that says "Script has been activated, Please wait." This is because a couple of times I opened mail and the script fired off and started to perform the action and I was in the middle of something. It was a momentary shock until I realized what was happening.

I will probably do something generic that can be used in all scripts, like a module. I have realized that when scripting using modular code seems to me the best way to go. Instead of always having to write the same code over and over, I can take blocks of code and plug them in where I need them.

So you may want to also consider adding some type of alert or writing a post-it note to place on your computer that says "Wait for mail rules to run" to remind yourself to give mail time to process the attached scripts to filtering rules you have setup. You'll have to decide what's best for you.

Thank you again John. Sorry for the slow response time. My wife and I have a small business where we typically work at least 6 days a week putting in about 14 hour a day, have a special needs child and keep chickens and ducks. I will be 60 in less than 6 months so I am moving a little more slowly than when I was younger. I want to find a flexible way to start learning apple script. I signed up for what I thought was a forum but it ended up being emails that seemed to be directed toward those who already know AppleScript. For me the issue is finding the time and a good resource. I have found one site that looks promising: http://macosxautomation.com/applescript/.

I say this with sincere humility but I thought that my ability to find the embedded Java at my credit union’s website and use it in the “Execute JavaScript in Safari” showed that I can learn those things I will need to create some really nice ‘automations’ on my Mac. Then as I stated earlier I want to be able to upload these macros and scripts for others to use.

I use mail rules a lot. I also use Mail Act-On. One thing I have learned from creating Hazel rules is to use a combination of items in my rule. So for renaming the bank statement from this credit union my rules are:
if the name is document,
the extension is pdf and
the body of the message contains my account number rename it …

In the case of this credit union I am thinking I can have the AppleScript identify it this way:
if the from is: notice@blucurrent.org and
the subject is: Your new eStatement is ready! then tell application “Keyboard Maestro Engine” to execute the script ….
Okay my inner nerd is kicking in when I say that I am already getting excited about learning AppleScript first and then follow JMichaelTX’s advice to learn Java. A funny coincidence my little brother whose goes by his middle name of Michael and whose first initial is J lives in Texas.

So I think I am getting the idea. First I have an AppleScript that will trigger KM when I get an email from my credit union that my statement is ready. The last thing is that I need another AppleScript that would do something like: if Desktop contains a file whose named ends with BluCurrent.pdf then logout of website in active tab of Safari. This should be some nice clean code without reference to mouse clicks. I will confess that I really prefer doing as much as possible from the keyboard. Mice have their place but I think in some instances they can slow one down. This may come from my DOS and Linux days.

Okay I did a little research and study. Here is what I have thus far and it works:

tell application "Mail"
  set theSelection to selection
  set theMessage to item 1 of theSelection
  subject of theMessage
end tell
--> "Your new eStatement is ready!"
tell application "Safari"
  if not running then run
  activate
end tell

I am bogged down on the correct way to add a 2nd condition. Here is what I had following the above but it was wrong:

tell application "Mail"
  set theSelection to selection
  set theMessage to item 2 of theSelection
  sender of the message
end tell
--> "notice@blucurrent.org"

Any guidance would be appreciated. Woo hoo AppleScript is cool.

Having fun?

Yep. This stuff is cool. Nothing like being able to (hopefully) get things to work the way you want them to! Are we actually saving time? Who cares??? :slight_smile:

Well Dan I don’t know if I am actually saving much time but it is good mental exercise which I want to keep up as I approach my 60th year of life. I am young at heart which also helps along with regular exercise. In my case this would be working outside, doing yoga, practicing marital arts, and swinging Indian Clubs. My belief is that we will have longer richer lives if we eat right while keeping physically and mentally fit.

Absolutely! I’m 59, and I started working out with a personal trainer last year, and it’s made a big difference. I’m actually fit enough to get back on the golf course with my wife, walking and carrying our bags (so I swing different kinds of clubs than you). And I’ve lost 30 pounds.

Mental exercise is indeed equally important, as you said. Though sometimes, when I’m fighting with a programming issue, I question whether it’s good for my mental health. But I tell the voices in my head to shut up, then everything’s fine! :open_mouth:

Just a comment or to use the AppleScript term an “Explanation”. Since I like audio-visual feedback I am going to start putting “Beep” into my AppleScripts.

1 Like

How about this?

1 Like

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