# Help with _IEFormGetObjByName

## Recommended Posts

Hello, my problem is this:I want to enter a user and password in a site, I took this to practice because it has a test zone in http://forums.linkbucks.com/newthread.php?...thread&f=12 and I looked at the example _IEFormElementSetValue that is in C:\Program Files\AutoIt3\Examples\Helpfile

The problem is that in this example (the _IEFormGetObjByName one that is also in C:\Program Files\AutoIt3\Examples\Helpfile )

; *******************************************************
; Example 1 - Get a reference to a specific form by name.  In this case, submit a query
;              to the Google search engine.  Note that the names of the form and form
;              elements can be found by viewing the page HTML source
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://www.google.com")$oForm = _IEFormGetObjByName ($oIE, "f")$oQuery = _IEFormElementGetObjByName ($oForm, "q") _IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
_IEFormSubmit ($oForm) It says "Note that the names of the form and form elements can be found by viewing the page HTML source" . Indeed, I went to the source code of google.com.uy and I found that the name of the form to search was "f" and then the "q" . Here it is the source code of google.com <html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Google</title><script>window.google={kEI:"niUjSqjgMcLflQeCsfnSAg",kEXPI:"17259,19363,20572,20665",kHL:"es"}; window.google.sn="webhp";window.google.timers={load:{t:{start:(new Date).getTime()}}};try{window.google.pt=window.gtbExternal&&window.gtbExternal.pageT()||window.external&&window.external.pageT}catch(b){} window.google.jsrt_kill=1; var _gjwl=location;function _gjuc(){var b=_gjwl.href.indexOf("#");if(b>=0){var a=_gjwl.href.substring(b+1);if(/(^|&)q=/.test(a)&&a.indexOf("#")==-1&&!/(^|&)cad=h($|&)/.test(a)){_gjwl.replace("/search?"+a.replace(/(^|&)fp=[^&]*/g,"")+"&cad=h");return 1}}return 0}function _gjp(){!(window._gjwl.hash&&window._gjuc())&&setTimeout(_gjp,500)};
})();
</script>

The problem is that when I open the source code of hotmail.com

<!-- ServerInfo: BY1IDSPLGN1I05 2009.05.08.01.28.02 Live1 Unknown LocVer:0 -->
<!-- PreprocessInfo: btsa007:TK1ESRVBLDA114,  -- Version: 6,500,12348,0 -->

<style type="text/css">
.cssBtnRest input{background-image: url(http://img.wlxrs.com/~Live.SiteContent.ID/~14.2.1230/~/~/~/btnbkgnd_rest.gif);}
.cssLT{background-image: url(http://img.wlxrs.com/~Live.SiteContent.ID/~14.2.1230/~/~/~/utbkgnd.gif);}
.cssLTMore{background-image: url(http://img.wlxrs.com/~Live.SiteContent.ID/~14.2.1230/~/~/~/utbkgnd.gif);}
.higbutton{background-image: url(http://img.wlxrs.com/~Live.SiteContent.ID/~14.2.1230/~/~/~/btnbkgnd_rest.gif);}
.higbuttonblue{background-image: url(http://img.wlxrs.com/~Live.SiteContent.ID/~14.2.1230/~/~/~/btnbkgnd_hot.gif);}
</style>
</body></html>

I don't find the "f1" that is the name of the form to enter the user (I suppose).

I would be glad if you can help me as well as if you can show me an easier way of making what I want. Sorry if I inserted too much code but I read in other posts that people asked for the code of what the others where doing so as to help them better. In any case I don't put too much code next time. :smt005

##### Share on other sites

I was able to find the needed input by this, IE Builder

http://www.autoitscript.com/forum/index.ph...st&p=133767

and here is how it works..

#include <IE.au3>
$oIE = _IECreate ("http://login.live.com")$oForm = _IEFormGetObjByName ($oIE, "f1")$oQuery = _IEFormElementGetObjByName ($oForm, "login") _IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
$oQuery2 = _IEFormElementGetObjByName ($oForm, "passwd")
_IEFormElementSetValue ($oQuery2, "AutoIt IE.au3") Sleep(10000) _IEFormSubmit ($oForm)

NOW!!!, you can TAKE this scriptlet and run with it... or use the IE Builder to understand where and how I got the needed data...So you can do this and more on your own later!!

8)

Edited by Valuater

##### Share on other sites

I was able to find the needed input by this, IE Builder

and here is how it works..

#include <IE.au3>
$oIE = _IECreate ("http://login.live.com")$oForm = _IEFormGetObjByName ($oIE, "f1")$oQuery = _IEFormElementGetObjByName ($oForm, "login") _IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
$oQuery2 = _IEFormElementGetObjByName ($oForm, "passwd")
_IEFormElementSetValue ($oQuery2, "AutoIt IE.au3") Sleep(10000) _IEFormSubmit ($oForm)

NOW!!!, you can TAKE this scriptlet and run with it... or use the IE Builder to understand where and how I got the needed data...So you can do this and more on your own later!!

8)

Thank you a lot! I will look into it for sure because I like to know how things work (I like to eat fish but I like more to fish hehe). Just a question: I downloaded the IE Builder but in that post you said we need "IE.au3 version T2.0-370 or later, and latest beta of course" but I have installed the latest full version of autoit (autoit-v3-setup) and the advanced version of scite (SciTE4AutoIt3) Do I need to install anything else?

PS:Nahuel35 from http://www.emesn.com/autoitforum/ recommended me www.debugbar.com and I wanted to share with you as it may prove useful for working with IE explorer

##### Share on other sites

Valuater: I wasn't able to run IE-library_v2.0 . I downloaded and installed the latest beta of autoit as well as the IE Builder and decompressed it in a folder in my desk. I read the problem from JerryD here http://www.autoitscript.com/forum/index.ph...st&p=133794 and I copied the file IE.au3 from C:\Program Files\Autoit\include\ into C:\Program Files\Autoit\beta\include\ as you said there but I keep getting this error

##### Share on other sites

Sorry for posting again but I don't know why I wasn't able to edit. I have another question I looked at your script but I can't find the form name to use in this url http://forums.linkbucks.com/newthread.php?...thread&f=12

Look at the source code, maybe I can't use _IEFormGetObjByName because the form there has javascript (i don't know i am wondering) and i should use another function maybe as it suggests in the helpfile "For many HTML forms it is not sufficient to use _IEFormSubmit() because there is often custom Javascript tied to an onclick event for its Submit button. In these cases you'll need to simulate a click of the submit button instead of using _IEFormSubmit(). See the example for the "click" action of _IEAction().

As well, some form processing relies on the "value" of the submit button being passed along with the rest of the form data (often when there is more than one submit button in the form and they are designed to trigger different results). This function will not result in a submit button value being passed. The solution is to use the "click" action of _IEAction() as above."

But how do I get to enter a reference to the username field or even to the button log in for instance?? I am quite confused Ok here is the code:

<FORM onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 0)" action=login.php method=post><INPUT type=hidden value=login name=do> <INPUT type=hidden value=/newthread.php?do=newthread&amp;f=12 name=url> <INPUT type=hidden name=vb_login_md5password> <INPUT type=hidden name=vb_login_md5password_utf> <INPUT type=hidden name=s> <!-- permission error message - user not logged in -->
<DIV class=smallfont>You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:</DIV>
<OL>
<LI class=smallfont>You are not logged in. Fill in the form at the bottom of this page and try again.
<LI class=smallfont>You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
<LI class=smallfont>If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation. </LI></OL>
<TBODY>
<TR>
<TR>
<TR>
<TR>
<TD align=right><INPUT class=button accessKey=s tabIndex=1 type=submit value="Log in"> <INPUT class=button accessKey=r tabIndex=1 type=reset value="Reset Fields"> </TD></TR></TBODY></TABLE></FIELDSET> </FORM>

##### Share on other sites

Valuater: I wasn't able to run IE-library_v2.0 . I downloaded and installed the latest beta of autoit as well as the IE Builder and decompressed it in a folder in my desk. I read the problem from JerryD here http://www.autoitscript.com/forum/index.ph...st&p=133794 and I copied the file IE.au3 from C:\Program Files\Autoit\include\ into C:\Program Files\Autoit\beta\include\ as you said there but I keep getting this error

replace the #Includes at the top with these new ones

#include <IE.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>

It should work fine

8)

## Create an account

Register a new account