Sign in to follow this  
Followers 0
PantZ4

Problems With _IEFormGetObjByName()

16 posts in this topic

I have this fuction there is automaticly logs on... but I have a problem:

Func Log_On()
    $x = $x + 1
    $window[$x] = _IECreate("www.arto.dk",0,1,0)
    $form = _IEFormGetObjByName ($window[$x], "")
    $login = _IEFormElementGetObjByName ($form, "brugernavn")
    $password = _IEFormElementGetObjByName ($form, "kodeord")
    $signin = _IEFormElementGetObjByName ($form, "action")
    
    $username = "your username here"
    $password2 = "your password here"

    _IEFormElementSetValue ($login, $username)
    _IEFormElementSetValue ($password, $password2)
    _IEAction ($signin, "click")
EndFuncoÝ÷ Ù8^¦ºé¢±«­¢+ØÀÌØí½É´ô}%½ÉµÑ=©   å9µ ÀÌØíÝ¥¹½ÝlÀÌØíát°ÅÕ½ÐìÅÕ½Ðì¤

The form does not have a name, so it cash everytime and does not fill any of them...

Error: X\AutoIt3\Include\IE.au3 (1245) : ==> The requested action with this object has failed.:

$o_col = $o_object.document.forms.item ($s_Name)

$o_col = $o_object.document^ ERROR

The Sides formulas:

Name:

Methode: post

Formula: http://www.arto.dk/r2/frames/navigation.asp

Name:

Methode: get

Formula: http://www.arto.dk/css/changeTheme.asp

Thank you :whistle:

Share this post


Link to post
Share on other sites



To get a reference to a form without a name, please see the function _IEFormGetCollection

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

Looks like the form is in a frame on that page, so it should help to grab the frame in an object variable, then use indexing and _IEFormGetCollection() on the frame object to put the form in an object variable. Then you have the rest already.


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

I have a question When i used helpfile script to scan for forms I got as a result 4 forms & all names were 0

with other words the forms dont have a name, this how the html code looks like:

So does this mean it is impossible to submit the info?

1.html

<FORM ACTION=show.php METHOD=post>
<TEXTAREA CLASS=in1 NAME=text ROWS=3 COLS=50></TEXTAREA><BR><BR>
<INPUT CLASS=in1 TYPE=submit NAME=post VALUE="OK" ><BR><BR>
<FORM ACTION=show.php METHOD=post>
<TEXTAREA CLASS=in1 NAME=text ROWS=3 COLS=50></TEXTAREA><BR><BR>
<INPUT CLASS=in1 TYPE=submit NAME=post VALUE="OK" ><BR><BR>

& this is the code I tried to use but...it only works for the first form, any ideas why its not working if I change the 0 ?

#include <IE.au3>
$oIE = _IECreate ("C:\1.html")
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetCollection ($oForm, 0)
_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
;~ _IEFormSubmit ($oForm)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

maybe I should have posted this in the first place, was my bad, did not notice:

well, hire are (Helpfile scan showed 2 forms), loginform & 0 but the wierd thing is, that the code only works for the loginform, this is wierd, because if I delete the loginform, then the code works perfect for the 0 form. if i use _IEFormGetCollection then the form names should not mather.Now the question Shouldnt the code be working?

<FORM NAME=loginform action=login.php method=post>
<TR><TD><B CLASS=menu>user</B></TD>
<TD><INPUT class=in1 maxLength=20 size=10 name=username></TD>
<TD><B CLASS=menu>pass</B></TD>
<TD><INPUT class=in1 type=password maxLength=20 size=10 name=password></TD>
</TR></FORM>

<FORM ACTION=login.php METHOD=POST>

<TR><TD WIDTH=50>user</TD>
<TD><INPUT CLASS=in1 SIZE=7 MAXLENGTH=20 TYPE=text NAME=username></TD>
</TR>
<TR> 
<TD WIDTH=50>pass</TD>
<TD><INPUT CLASS=in1 SIZE=7 MAXLENGTH=20 TYPE=password NAME=password></TD>
</TR>
</TABLE>
</FORM>

1.html

Edited by chie

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

_IEFormGetCollection only grabs the form you specify, as you see there are 2 <Form> tags that means the first 2 forms are for 0 and the second 2 forms are for 1 using @extended you can grab how many forms, and elements are in the form as ive shown here

#include <IE.au3>
$oIE = _IECreate (@DesktopDir & "\1.html",0,1)
_IELoadWait($oIE)
_IEFormGetCollection($oIE)
For $j = 0 to @extended - 1
$oForm = _IEFormGetCollection ($oIE,$j)
For $i = 0 to @extended - 1
$oQuery = _IEFormElementGetCollection ($oForm, $i)
_IEFormElementSetValue ($oQuery, "Form" & $j & " Value" & $i)
Next
Next
Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

this was really helpful info, i think i understand, so if i change it to For $j = 1 to 1 & For $i = 0 to 0 it will input the info into the third box, otherwise it will input all boxes on the site.

But can i ask you 1 more question? on the page im trying to use this, there is insane amount of code, but finally(after hours of experimenting) i think i managed to find the peace of code that wont let me input the info into the box:

its because of the <INPUT...things even with 1 <INPUT....it stops working... if i delete them it works....but i cant delete them from original site, so i was wondering if you can give a hand 1 more time?

<FORM ACTION=show.php METHOD=post onsubmit="post.disabled=true;">
<INPUT TYPE=hidden NAME=act VALUE=confirm>
<INPUT TYPE=hidden name=group value=F>
<INPUT TYPE=hidden name=age1 value="">
<INPUT TYPE=hidden name=age2 value="">
<INPUT TYPE=hidden NAME=itemid VALUE=9674458>
<INPUT TYPE=hidden NAME=a1af8adafaa19ca6dce58206a3820d064 VALUE=cb4928b615eac3bc9362>

<TEXTAREA CLASS=in1 NAME=text ROWS=7 COLS=50></TEXTAREA><BR><BR>
</FORM>

Share this post


Link to post
Share on other sites

what is the link to the website

Share this post


Link to post
Share on other sites

so u want it to fill in text to the Kommenteeri?

#include <IE.au3>
$oIE = _IECreate("http://www.rate.ee/")
$oForm = _IEFormGetCollection($oIE,0)
$Username = _IEFormElementGetObjByName($oForm,"username")
$Password = _IEFormElementGetObjByName($oForm,"password")
_IEFormElementSetValue($Username,"testuser2")
_IEFormElementSetValue($Password,"123456")
_IEFormSubmit($oForm)
_IENavigate($oIE,"http://www.rate.ee/show.php")
$oForm = _IEFormGetCollection($oIE,0)
$Kommenteeri = _IEFormGetObjByName($oForm,"text")
_IEFormElementSetValue($Kommenteeri,"Text to say")
_IEFormSubmit($oForm)

not tested it should put Text to say in the komenteeri box

Share this post


Link to post
Share on other sites

so u want it to fill in text to the Kommenteeri?

Yes. I tried this code you poosted already actyally &, nop it was not working with the site nor the 1.html file, The error message I always got with this was, (it submitted last, radio box 8),(as you see there are 8 Radio Boxes on the top).

I also tried that @extended... thing & also no progress(even though it should fill all text areas.....theoretically )

1.html

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

You obviously don't understand how to use IE.au3 UDF because your just doing random stuff hoping for it to work

try this accidently didnt put 1 cuz the komenteeri is on the second form

EDIT: nope its actualy on the 3rd one, nope not that either

#include <IE.au3>
$oIE = _IECreate("http://www.rate.ee/")
$oForm = _IEFormGetCollection($oIE,0)
$Username = _IEFormElementGetObjByName($oForm,"username")
$Password = _IEFormElementGetObjByName($oForm,"password")
_IEFormElementSetValue($Username,"testuser2")
_IEFormElementSetValue($Password,"123456")
_IEFormSubmit($oForm)
_IENavigate($oIE,"http://www.rate.ee/show.php")
$oForm = _IEFormGetCollection($oIE,3)
$Kommenteeri = _IEFormGetObjByName($oForm,"text")
_IEFormElementSetValue($Kommenteeri,"Text to say")
_IEFormSubmit($oForm)
Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

try this accidently didnt put 1 cuz the komenteeri is on the second form

EDIT: nope its actualy on the 3rd one, nope not that either

Actyally I have tryed this already also, even up to _IEFormGetCollection($oIE,30) & as far as I understand, ONLY the form submit works when _IEFormGetCollection($oIE,0) is used(but then it only submits the radio box labeled 10), for any other number it wont even submit the form, & it wont input the "Text to say" neather way. well first I used the 1.html to see if it works at all, & it wasnt, then just in case I also tried it with the site & it was not working neather. :lmao:

Side Note!: this makes me want to submit the "Text to say" into this textarea even more than before ;)

Share this post


Link to post
Share on other sites

DOHHHHH i was using IEFormGetObjByName instead of IEFormElementGetObjByName my bad

Share this post


Link to post
Share on other sites

DOHHHHH i was using IEFormGetObjByName instead of IEFormElementGetObjByName my bad

YEs it works now. Thank you wery mutch, I need to experiment(learn) more now to be able to use it on any site now, Oh forgot this can even input into the hidden form & submit it ( example click a link & form will appear ) without waisting time on opening it. (Just discovered that ;) )

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