| View previous topic :: View next topic |
| Author |
Message |
drmurdoch
Joined: 10 Nov 2006 Posts: 110
|
Posted: Sun Jun 17, 2007 7:24 pm Post subject: control Internet Explorer login and form submission |
|
|
I have a website that is IE only. I want to find a method of logging my into a site, submit some information ... and then click search.
I would like to pass a variable to this automation script.
For FireFox, I use a program called Chicken Foot. It works well.
Is there any AHK script that controls the browser as outlined ? |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 8255 Location: Maywood, IL
|
Posted: Sun Jun 17, 2007 7:29 pm Post subject: |
|
|
this is a fairly common question. you can probably make this script work. Please search the forum for javascript, bookmarklets, waiting for a page to load, IE4AHK, and related terms. Everything you need has been posted. _________________
(Common Answers) |
|
| Back to top |
|
 |
drmurdoch
Joined: 10 Nov 2006 Posts: 110
|
Posted: Sun Jun 17, 2007 7:33 pm Post subject: it would go like this ... |
|
|
go to the website
wait a little bit
type login
Tab
password1
Tab
password2
Tab
Enter Key
Wait
hit Tab key 14 times [Enter] or go to another web page
Wait
Hit Tab key 3 times
enter User Number (I'd like this a variable)
Hit Tab 7 times.
Enter
What is the best script to do this with ? |
|
| Back to top |
|
 |
Travley
Joined: 13 May 2007 Posts: 47
|
Posted: Sun Jun 17, 2007 8:49 pm Post subject: |
|
|
AHK would be a good usage for This. It'd look something like this
| Code: | usernumber = whatever
login = whatever
pass1 = whatever1
pass2 = whatever2
siteurl = http://www.yoursite.com
delay = 6000 ; in milisec (6000 = 6seconds)
Run %siteurl%
Sleep, %delay%
Send %login%
Send {tab}
Send %pass1%
Send {tab}
Send %pass2%
Send {tab}
Send {Enter}
Sleep, %delay%
Send {tab 14}
Send {Enter}
Sleep, %delay%
Send {tab 3}
Send %usernumber%
Send {tab 7}
Send {Enter}
Return |
It could be more simplified, but I hope this helps. I recommend checking out the AutoScriptWriter that came with AHK. I generally do what I need to do once with that running, and go back and review. Def-useful program. |
|
| Back to top |
|
 |
drmurdoch
Joined: 10 Nov 2006 Posts: 110
|
Posted: Sun Jun 17, 2007 9:16 pm Post subject: works. |
|
|
Thank you.
I got it to work.
Now I just need a way of pulling the UserNumber from a program I use !
Thank you.
| Code: | ;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other <myemail@nowhere.com>
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
accoutnumber = 24601
login = mylogin
pass1 = mypass1
pass2 = mypass2
siteurl = http://www.corporateURL.com
delay = 3000 ; in milisec (6000 = 6seconds)
Run, c:\Program Files\Internet Explorer\iexplore.exe %siteurl%
Sleep, %delay%
Send %login%
Send {tab}
Send %pass1%
Send {tab}
Send %pass2%
Send {tab}
Send {Enter}
Sleep, %delay%
Send {tab}
Send https://www.corporateURL.com/results/search_frame.asp
Send {Enter}
Sleep, %delay%
Send {tab 3}
Send %usernumber%
Send {tab 7}
Send {Enter}
Return |
|
|
| Back to top |
|
 |
drmurdoch
Joined: 10 Nov 2006 Posts: 110
|
Posted: Sun Jun 17, 2007 9:21 pm Post subject: what about command line |
|
|
Is there a way pass a variable to this script ? Maybe via a command line ?
my script it called logintoaccountx.ahk
accountnumber is what I want to pass.
How might it work like this ...
c:\Program Files\AutoHotkey\Scripts\logintoaccountx.ahk 9894954934
Thank you  |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 8255 Location: Maywood, IL
|
Posted: Sun Jun 17, 2007 10:31 pm Post subject: |
|
|
the command parameter is passed as a variable with the number of the parameter
| Code: |
if %0% = 1
Msgbox, One parameter received - %1%
else
Msgbox, No parameters (or too many) received! %0%
|
_________________
(Common Answers) |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Sun Jun 17, 2007 10:35 pm Post subject: |
|
|
Add the following to be the firstline of your script:
| Code: | | AccountNumber = %1% |
 |
|
| Back to top |
|
 |
drmurdoch
Joined: 10 Nov 2006 Posts: 110
|
Posted: Mon Jun 18, 2007 12:27 am Post subject: Thank you. |
|
|
AccountNumber = %1% <--- syntax reminds me of batch files now that I think of it.
Thank you.
 |
|
| Back to top |
|
 |
drmurdoch
Joined: 10 Nov 2006 Posts: 110
|
Posted: Mon Jun 18, 2007 12:59 am Post subject: sooooooooooooooooooooooo close. |
|
|
I was told I can't do it the command line
I have two ways to do it.
1) parse the results from this URL
http://127.0.0.1:8001/searchresults.html
I would look for "accountnumber: 1384411291DT" (and I would need to read the first 10 digits (not the letters, if they existed). 1384411291DT would vary depending on the account selected.
or
2) I need to read the number from a file.
The file looks like this .... and is located in this directory
c:\clients\account\www\searchresults.html
<html><body><h2>Search ...</h2>You need to write a <a href=http://groups.csail.mit.edu/uid/chickenfoot/>chickenfoot script</a> and trigger it on this page to run your custom searches. This also requires Firefox.<p/>Surname: Surname<br/>Given: SELMA<br/>(dd-mmm-yyyy) Dob1: 4-Nov-1926<br/>(dd/mm/yyyy) Dob2: 4/11/1926<br/>(mm/dd/yyyy) Dob3: 11/41926<br/>accountnumber: 1384411291DT<br/></body></html>
Ideas ? |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Mon Jun 18, 2007 1:44 am Post subject: |
|
|
| Code: | FileRead, HTML, c:\clients\account\www\searchresults.html
SearchStr := "accountnumber: "
FoundPos := InStr( HTML, SearchStr )
If FoundPos
AccountNumber := SubStr( HTML, FoundPos+StrLen(SearchStr), 10 )
HTML :=
MsgBox, % AccountNumber |
 |
|
| Back to top |
|
 |
drmurdoch
Joined: 10 Nov 2006 Posts: 110
|
|
| Back to top |
|
 |
drmurdoch
Joined: 10 Nov 2006 Posts: 110
|
Posted: Mon Jun 18, 2007 1:50 am Post subject: |
|
|
OMG. thanks. I will try !
I was struggling.
! |
|
| Back to top |
|
 |
drmurdoch
Joined: 10 Nov 2006 Posts: 110
|
Posted: Mon Jun 18, 2007 2:02 am Post subject: |
|
|
Works !
| Code: | FileRead, HTML, c:\clients\account\www\searchresults.html
SearchStr := "accountnumber: "
FoundPos := InStr( HTML, SearchStr )
If FoundPos
AccountNumber := SubStr( HTML, FoundPos+StrLen(SearchStr), 10 )
;HTML :=
;MsgBox, % AccountNumber |
I commented out the HTML and the Msgbox thing.
Should I close the If ? |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Mon Jun 18, 2007 2:11 am Post subject: |
|
|
| Quote: | | I commented out the HTML |
You would know better! If searchresults.html was a 10MB file then the variable HTML will be using 10MB of memory. You cannot delete a variable once it has been created but can reset it to null, to conserve memory.
| Quote: | | Should I close the If ? |
Not needed! That is one sweetest thing of AHK syntax.  |
|
| Back to top |
|
 |
|