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 > Using Automater or AppleScript to Log into website each day

Using Automater or AppleScript to Log into website each day
Thread Tools
liq2
Fresh-Faced Recruit
Join Date: Oct 2005
Status: Offline
Reply With Quote
Jan 1, 2007, 08:01 PM
 
I need a script or automation function that will automatically log into CRM Software Leader | Customer Relationship Management (CRM) each morning during the workweek. I'd like the time to vary in a 10 min window each day. Is there a way that i can set this up? Are there any available resources or examples that i could draw from? is this even possible??

thanks in advance!
     
stravinsky1911
Junior Member
Join Date: Mar 2003
Location: Knoxville
Status: Offline
Reply With Quote
Jan 2, 2007, 12:21 AM
 
Me too! Please!
timeline - SE/30, some crappy performa, original bondi iMac 233, TiBook500, macbook pro 2GHz
     
JKT
Professional Poster
Join Date: Jan 2002
Location: London, UK
Status: Offline
Reply With Quote
Jan 2, 2007, 04:14 AM
 
Such an ability would probably be a massive security hole in the OS, so hopefully it isn't!
     
RevEvs
Mac Elite
Join Date: Feb 2001
Location: Sitting in front of computer
Status: Offline
Reply With Quote
Jan 2, 2007, 05:58 PM
 
Im sure its possible. Maybe with AppleScript UI scripting?
I free'd my mind... now it won't come back.
     
Z's Mac
Fresh-Faced Recruit
Join Date: Jan 2007
Location: In front of my Mac
Status: Offline
Reply With Quote
Jan 21, 2007, 02:06 AM
 
I know I'm three weeks late, but do you still want this script?
     
liq2  (op)
Fresh-Faced Recruit
Join Date: Oct 2005
Status: Offline
Reply With Quote
Jan 21, 2007, 06:20 PM
 
yeah, please send it over..thanks!!
     
Z's Mac
Fresh-Faced Recruit
Join Date: Jan 2007
Location: In front of my Mac
Status: Offline
Reply With Quote
Jan 21, 2007, 11:53 PM
 
I think the following will work for you (worked for me, except for not having a username or password). As it's set up now, it would login everyday at 8am, give or take 10 minutes (provided your computer isn't in sleep mode). Let me know if you have any problems/questions.

set runDate to 0
repeat
--The next three lines create variation in execution time.
--If you don't want any variation, just change
--the numbers in the first line to 0.
--Otherwise, the action will occur plus or minus
--the number of seconds you set
set timeVariation to random number from -600 to 600
set theDate to current date
set randomTime to (time of theDate) + timeVariation

--this set up makes sure the program only runs once
--per day
if runDate is day of theDate then
delay 60
else
--the following line is the time of execution in seconds
--past midnight. So 8am is 8 hours X 60 minutes X 60 seconds
--which is 28800. If you have variation set above, then include
--that in the calculation. Therefore, 10 minutes (600 seconds)
--of variation either way would be > 28200 and < 29400.
--Because the script checks the time once per minute (to reduce
--the amount of cpu usage, you should have at least 2 minutes
--of buffer time (e.g. > 28140 and <29460)
if randomTime > 28140 and randomTime < 29460 then

--Replace with Browser of choice (I know Safari and Firefox will both work)
tell application "Firefox"
Get URL "https://www.salesforce.com/login.jsp"
end tell

--The following delay allows the page to load (sometimes it took a while)
delay 15

tell application "Firefox" --again, replace with right browser
activate --this is required to bring the app to the front.
end tell
tell application "System Events"
tell process "Firefox"
keystroke "UserName" & tab --keep quotes, use your own username
delay 0.5
keystroke "Password" & return --keep quotes, use your p/w
delay 1200 --how many seconds do you want to stay logged in?
--make sure its at least equal to total variation or there's
--a chance you'll execute the script twice in a day.
end tell
end tell
set runDate to day of theDate
else
delay 60
end if
end if
end repeat
( Last edited by Z's Mac; Jan 22, 2007 at 12:02 AM. Reason: Further explain the current settings.)
     
Z's Mac
Fresh-Faced Recruit
Join Date: Jan 2007
Location: In front of my Mac
Status: Offline
Reply With Quote
Jan 27, 2007, 11:30 AM
 
1) Did you implement the script liq2?

2) Parsimony is always a good goal, does anyone know of an easier (e.g. less code) way to execute the task daily with the ten minute window? Ideally it would be good to not have to run the script every minute to see if it's time to run the script.
     
itai195
Addicted to MacNN
Join Date: May 2001
Location: Cupertino, CA
Status: Offline
Reply With Quote
Jan 28, 2007, 05:31 AM
 
For (2), why not use launchd or an iCal alarm?
     
Z's Mac
Fresh-Faced Recruit
Join Date: Jan 2007
Location: In front of my Mac
Status: Offline
Reply With Quote
Jan 28, 2007, 11:07 AM
 
Both launchd and iCal would allows the script to be run at a specific time. However, the request was for a 10 minute variation in start time. Is there a way, using launchd or iCal, to have a random (within 10 minutes) start time?
     
Mithras
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status: Offline
Reply With Quote
Jan 28, 2007, 12:19 PM
 
Well, you could just launch the script at a determined time, and then have the script begin with a random delay.
     
itai195
Addicted to MacNN
Join Date: May 2001
Location: Cupertino, CA
Status: Offline
Reply With Quote
Jan 29, 2007, 04:39 AM
 
I guess I don't get the point of the 10 minute window, but yeah Mithras that would work.
     
Z's Mac
Fresh-Faced Recruit
Join Date: Jan 2007
Location: In front of my Mac
Status: Offline
Reply With Quote
Jan 29, 2007, 09:52 AM
 
Originally Posted by Mithras View Post
Well, you could just launch the script at a determined time, and then have the script begin with a random delay.
That's a good idea. Didn't think of that.

Originally Posted by itai195 View Post
I guess I don't get the point of the 10 minute window, but yeah Mithras that would work.
I'm guessing the reason the original request asked for a 10 minute window was because if he logged in at exactly the same time every day it would be an obvious automation. Possibility is that he wants to appear to be at work?
     
   
 
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
Top
Privacy Policy
All times are GMT -4. The time now is 07:44 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,