Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Applications > Automate log-in using applescript

Automate log-in using applescript
Thread Tools
Fresh-Faced Recruit
Join Date: Jan 2011
Status: Offline
Reply With Quote
Jan 19, 2011, 01:52 PM
 
Hi,
I am in desperate need of a script to help log in to a mail website. Currently I have to access a mail system through a web browser (safari or other) using a two-step log-in. On the first page I have to put in a username and then a password composed of a fixed code and a random string generated by a key-fob that I carry. I then hit return and am directed to a new page where I put in a username and fixed password, hit enter and then am directed to my in-box.

Unfortunately, the site logs me off after only a few minutes of inactivity, so I end up spending most of my time doing this incredibly cumbersome log-in routine all the time - sometimes even after reading only one email. I am told that there is no way to pull my emails down to my laptop using an email client with this system.

So, I would like to create a script which would
1. Open a browser window and navigate to login page 1
2. Enter predefined username in field 1
3. Enter predefined password string in field 2
4. Invite user to enter string to append to password in field 2
5. Select return
6. Wait for next page to appear
7. Enter predefined username string in field 1
8. Enter predefined password in field 2
9. Select (click) submit button

So far, I have the following script:


tell application "Safari"
activate
do JavaScript "window.open('http://myemailsite.com')" in document 1
end tell
tell application "System Events"
tell process "SystemUIServer"
keystroke "myusername"
end tell
end tell


It does navigate to the site, but unfortunately it only sometimes will fill in the "username". I have not figured out why it only does this sometimes but not others. I am also not sure how to get it to hit "return" and navigate to the next page.

Any thoughts GREATLY appreciated.
     
Posting Junkie
Join Date: Dec 2000
Status: Offline
Reply With Quote
Jan 19, 2011, 02:27 PM
 
Add a short delay in there so that it doesn't try to type the username when the page has not yet loaded (or before the scripts on the page have moved keyboard focus to the username field).

Ticking sound coming from a .pkg package? Don't let the .bom go off! Inspect it first with Pacifist. Macworld - five mice!
     
Mac Enthusiast
Join Date: Feb 2005
Status: Offline
Reply With Quote
Jan 20, 2011, 11:11 AM
 
Maybe the LastPass.com browser extension could help with automatically filling-in the username and the fixed portion of the password? It can handle multi-step logins i think.
     
Clinically Insane
Join Date: Jun 2001
Location: planning a comeback !
Status: Offline
Reply With Quote
Jan 20, 2011, 02:13 PM
 
OT: why do you need to check enmails every few minutes ?

Surely, if this is the system you are provided, you can't be expected to read / react to emails within minutes.
Just limit your email checking / processing to 3 times a day, and do other things the rest of the time.

This obsession with checking and reading emails all the time ASAP is a productivity killer.

-t
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:35 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2