Jump to content

Log into website using a form


wolle7
 Share

Recommended Posts

Hi,

I'm new on autoit, so I searched a lot around the forum and found several threads but none of the did give me the right way. I want to log into a website e.g. on http://www.gmx.net/ there is a form with the name "login" and there are two input fields one named "id" and the other is named "p" after that the button "inpLoginSubmit" should be pressed.

I do not use a solution with sending TABs. Is it later possible to hide the Internet Explorer because I'd like to automate something, but first for the time I write that script I want so see what happens.

May some give me a quick start on that ? That would be great ! The first start is always the hardest one, but after that it's easier to find how autoit works really and I'm sure I will be able to help others soon - hopefully :)

Cheers Wolle

Cheers Wolle

Link to comment
Share on other sites

Wolle,

Please refer to the help file under User Defined Fucntions > IE Management. This section should have everything you need to submit a form. All the examples in there are great!

Thanks,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Thanks for that big hint, if you know where to search it's going quickly :)

Here what I've written - seems to work fine any comment's or tips ?

#include <IE.au3>
ShellExecute ("iexplore.exe", "about:blank")
WinWait ("Leere Seite")
$oIE = _IEAttach ("about:blank", "url")
_IELoadWait ($oIE)
_IENavigate ($oIE, "www.gmx.de")
_IELoadWait ($oIE)

$o_form = _IEFormGetObjByName ($oIE, "login")
$o_login = _IEFormElementGetObjByName ($o_form, "id")
$o_password = _IEFormElementGetObjByName ($o_form, "p")
$o_signin = _IEFormElementGetObjByName ($o_form, "inpLoginSubmit")

$username = "my username"
$password = "my password"


_IEFormElementSetValue ($o_login, $username)
_IEFormElementSetValue ($o_password, $password)
_IEAction ($o_signin, "click")

Cheers Wolle

Cheers Wolle

Link to comment
Share on other sites

Just one big important question. Do I have to close the connection or something like that or is my code above just fine ?

Thx Wolle

//edit

The line: WinWait ("Leere Seite")

I don't like because it's language dependant. Is there another way to wait till the new explorer instance has started ?

Edited by wolle7

Cheers Wolle

Link to comment
Share on other sites

You don't have to close the connection or sockets or anything like that. IE handles that for you.

You are using IE like an API (thanks Dale) passing it the info then it deals with the rest.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

Wolle,

I wanted to commend you for taking the search suggestions and running with it in a manner that allowed you to create your own script. A lot of new people to the forum expect you to "give" them something. I like how you were able to take a search suggestion, and make it happen for yourself. I hope you have a lot of great AutoIt scripting experiences! We're here to help people like you make things happen!

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Thanks for that big hint, if you know where to search it's going quickly :)

Here what I've written - seems to work fine any comment's or tips ?

#include <IE.au3>
ShellExecute ("iexplore.exe", "about:blank")
WinWait ("Leere Seite")
$oIE = _IEAttach ("about:blank", "url")
_IELoadWait ($oIE)
_IENavigate ($oIE, "www.gmx.de")
_IELoadWait ($oIE)

$o_form = _IEFormGetObjByName ($oIE, "login")
$o_login = _IEFormElementGetObjByName ($o_form, "id")
$o_password = _IEFormElementGetObjByName ($o_form, "p")
$o_signin = _IEFormElementGetObjByName ($o_form, "inpLoginSubmit")

$username = "my username"
$password = "my password"


_IEFormElementSetValue ($o_login, $username)
_IEFormElementSetValue ($o_password, $password)
_IEAction ($o_signin, "click")

Cheers Wolle

The single call:

$oIE = _IECreate(""www.gmx.de")

Will replace this entire block:

ShellExecute ("iexplore.exe", "about:blank")

WinWait ("Leere Seite")

$oIE = _IEAttach ("about:blank", "url")

_IELoadWait ($oIE)

_IENavigate ($oIE, "www.gmx.de")

_IELoadWait ($oIE)

Also, many functions, Including _IECreate and _IENavigate, call _IELoadWait for you. There is no harm is calling it again, but it is unnecessary.

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

Link to comment
Share on other sites

@Jarvis

Thanks, YOU gave me what I exactly needed :)

@Dale

I wrote this entire block, because I read that so a cookie will not be shared with an other IE session, and that's fine :)

But I don't like the statemanet with WinWait but I don't know how I could change it, a simple sleep is not what I'm looking for.

Wolle

Cheers Wolle

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...