Sign in to follow this  
Followers 0
CleaverX

Open a web page with IE

14 posts in this topic

Hello folks, Mr Noob here, how is everyone?

Well the title says it all. My wife hates to have to manually sign in at this one portal that she uses often.

The people that coded the web site do not allow for auto logon using cookies. So, I wrote an autoit script that does that for her. It works, but....it's lame!!!!

This web site does not like Firefox, so she has to use IE. so here is how I am getting it done:

Run("C:\Program Files\Internet Explorer\iexplore.exe -nohome");opens a blank page in IE
WinWaitActive("Microsoft Internet Explorer");waits for the page to open
WinSetState("Microsoft Internet Explorer", "", @SW_MAXIMIZE);maximizes the page for precise mouse control
ControlSetText("Microsoft Internet Explorer", "", 41477, "https://my.portal.com");sets the address
MouseClick("left", 995, 95);clicks the 'GO' button at the end of the address bar
WinWaitActive("My Portal - Microsoft Internet Explorer");waits for the page to open
Sleep(5000);pauses 5 seconds to make sure the page is done loading
Send("{CAPSLOCK}username{TAB}password{TAB}{TAB}{ENTER}");auto fills the user name and pw fields
                                                        ; clicks the 'Log on' button
Sleep(5000);pauses 5 seconds to make sure the page is done loading
MouseClick("left", 85, 415);clicks the link to the destination page

After you folks are done laughing, pleeeease set me straight.

I have no pride, and all comments are welcome.

Thanks

Share this post


Link to post
Share on other sites



Hm, thats the kind of code i use and i use it to navigate whole web sites. I don't really know another way... But i also like the mouse moving by itself effect.

Share this post


Link to post
Share on other sites

You can also pass the location to iexplore.exe through the command line.

iexplore.exe https://my.portal.com

Share this post


Link to post
Share on other sites

You can use IE.au3 to automate this. If the code you use works, I wouldn't worry about it. Coding is a art, not a science. I've been slammed to the curb more than once for how I coded something. Usually the person's intent was good, and I did learn something, but now and again you will get someone who thinks the code just sucks and is more than eager to tell you. If you are willing to learn, and I strongly believe you are, look into using IE.au3. You can get to it from this link: http://www.autoitscript.com/forum/index.ph...46entry180446

Share this post


Link to post
Share on other sites

way 1: RegRead your default browser path (forgot the key but its there)

way2: make the computer figure it out:

Run(@ComSpec & " /C " & "Start http://www.google.com/", "", @SW_HIDE)

Share this post


Link to post
Share on other sites

Hello folks, Mr Noob here, how is everyone?

Well the title says it all. My wife hates to have to manually sign in at this one portal that she uses often.

The people that coded the web site do not allow for auto logon using cookies. So, I wrote an autoit script that does that for her. It works, but....it's lame!!!!

This web site does not like Firefox, so she has to use IE.

CleaverX,

If you want to try the way vollyman suggested, try this:

; my.portal - Login.au3
#include <IE.au3>
$o_IE = _IECreate ()
_IENavigate ($o_IE, "https://my.portal.com")
WinSetState("", "", @SW_MAXIMIZE)
Send("USERNAME"); Replace USERNAME with your username.
Send("{tab}")
Send("PASSWORD"); Replace PASSWORD with your password.
Send("{tab}")
Send("{enter}")
Exit

And welcome to the AutoIt Forum. :D

taurus905


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Or consider this Hotmail login example that does it all with IE.au3:

#include <IE.au3>
; Create a browser window and navigate to hotmail
$oIE = _IECreate("http://www.hotmail.com")

; get pointers to the login form and username, password and signin fields
$o_form = _IEFormGetObjByName($oIE, "f1")
$o_login = _IEFormElementGetObjByName($o_form, "login")
$o_password = _IEFormElementGetObjByName($o_form, "passwd")
$o_signin = _IEFormElementGetObjByName($o_form, "SI")

$username = "your username here"
$password =  "your password here"

; Set field values and submit the form
_IEFormElementSetValue($o_login, $username)
_IEFormElementSetValue($o_password, $password)
_IEAction($o_signin, "click")

Exit

Dale

Edit: removed _IENavigate and combined with _IECreate

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Thanks to all who replied!!

The posts that referenced the IE.au3 includes were the most fascinating and professional.

Are there any ways (without the use of the IE include) to determine when a web page is done

loading? Perhaps a small example of how to run a VBScript in autoit would do.

Thanks again!!! And my wife thanks you. She is no longer frustrated, in fact she thinks the whole

auto logon thing is the coolest ever!!

The Cleaver

Share this post


Link to post
Share on other sites

Or consider this Hotmail login example that does it all with IE.au3:

#include <IE.au3>
; Create a browser window and navigate to hotmail
$oIE = _IECreate("http://www.hotmail.com")
; get pointers to the login form and username, password and signin fields
$o_form = _IEFormGetObjByName($oIE, "f1")
$o_login = _IEFormElementGetObjByName($o_form, "login")
$o_password = _IEFormElementGetObjByName($o_form, "passwd")
$o_signin = _IEFormElementGetObjByName($o_form, "SI")
$username = "your username here"
$password =  "your password here"
; Set field values and submit the form
_IEFormElementSetValue($o_login, $username)
_IEFormElementSetValue($o_password, $password)
_IEAction($o_signin, "click")
Exit

Dale

Edit: removed _IENavigate and combined with _IECreate

What about if the button to login does not have a name as with my ISP web mail page? How could I click on this button?

<input type="submit" class="button" title="Once youve entered your Username and password, click on the Log in button to check your email account."

value="Log in"

onmouseover="return hint('Once youve entered your Username and password, click on the Log in button to check your email account.')"

onmouseout="return hint()">

Share this post


Link to post
Share on other sites

What about if the button to login does not have a name as with my ISP web mail page? How could I click on this button?

See _IEFormElementGetCollection($oForm, $index) instead of _IEFormElementGetObjByName

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Sorry to revive an old thread, but this is very close to my issue, as I am trying to automate logging into a website. My problem is, site I am trying to log in to has no name, so

$o_form = _IEFormGetObjByName($oIE, "f1")

won't work for me. How else could I go about this? ( I understand that f1 is the name of the form for the hotmail site. When I use the IE-Builder on my website, it does not name my form)

*Edit, because I missed a sentence.

Edited by crambaza

Share this post


Link to post
Share on other sites

I'm sorry, I figured it out. Although I am sure there is an elegant way to have it.

$o_form = _IEFormGetCollection ($oIE, 0)
$o_form = _IEFormElementGetCollection( $o_form )

Have a great day.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0