Jump to content

IE get object


 Share

Recommended Posts

I want to get an object in a form that doesnt has a name, only method

like this:

<form action="http://www.altavista.com/" method=get>

how can i get it? i used get collection but yet the result is nothing

EDIT: i may have to ask the IE creator for this..., does noone knows?

Edited by c4nm7
Link to comment
Share on other sites

Can you show some code? _IEFormGetCollection with the optional index passed is typically the way to do it. Perhaps there are frames involved and you aren't looking in the right container for the forms...

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

Can you show some code? _IEFormGetCollection with the optional index passed is typically the way to do it. Perhaps there are frames involved and you aren't looking in the right container for the forms...

Dale

this is the code of the site:

<form action="http://www.altavista.com/" method=get>
        <td valign=top><b class=m><font color=#0000000>
Îâ¢Î»Î»Î·Î½Î¹ÎºÎ¬ :</font></b></td>
       </tr>       <tr>
        <td bgcolor=white class=s><div style=padding:10px;>asdas δ</div></td>
       </tr>
       <tr>
        <td class=s><input type=hidden name="q" value="asdas δ"><input type="hidden" name="kls" value="0">

and this is mine:

$collection = _IEFormGetCollection($oIE)
        MsgBox(0, "Colection", $collection)
        $oresult = _IEFormGetObjByName ($oIE, "get")
         $object = _IEGetObjByName($oIE, "q")
        $control = _IEFormElementGetValue($object)
         GUICtrlSetData($textto, $control)

the collection returns nothing and the _IEFormGetObjByName ($oIE, "get") doesnt respond cause it's method not name

EDIT:the weird symbols are greek which this forum doesnt support

Edited by c4nm7
Link to comment
Share on other sites

collection... from help using your address

#include <IE.au3>
$oIE = _IECreate ("http://www.altavista.com")
$oForms = _IEFormGetCollection ($oIE)
MsgBox(0, "Forms Info", "There are " & @extended & " forms on this page")
For $oForm In $oForms
    MsgBox(0, "Form Info", $oForm.name)
Next

no time to work on it more

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

collection... from help using your address

#include <IE.au3>
$oIE = _IECreate ("http://www.altavista.com")
$oForms = _IEFormGetCollection ($oIE)
MsgBox(0, "Forms Info", "There are " & @extended & " forms on this page")
For $oForm In $oForms
    MsgBox(0, "Form Info", $oForm.name)
Next

oÝ÷ Úz-g­£
+â¶j+{Ïêº^²¦ºËn±é¶q«¬zØ^­è¬Ú殶­sbb33c¶ôfÒÒôTf÷&ÔvWD6öÆÆV7Föâb33c¶ôRÂÓ f÷"b33c·6¶¶âb33c¶ôfТ×6t&÷ÂgV÷C·7"gV÷C²Âb33c·6¶¶æÖWFöB æWB

but if i use _IEFormGetCollection($oIE, 0) or even _IEFormGetCollection($oIE, 1) the result is nothing

how can i get the 1st of the 2 forms and use it with _IEFormElementGetObjByName () ?

Link to comment
Share on other sites

ok i got the result but now i want to get the value of an element in this form

this is the code:

$oFm = _IEFormGetCollection($oIE, 0)
$sere = $oFm.method
;until here fine
$lement =  _IEFormElementGetObjByName($sere, "q")
;that's the problem the element is not found                
$control = _IEFormElementGetValue($lement)
MsgBox(0, "asd", $control)

this is the site's source:

<form action="http://www.altavista.com/web/results" method=get>
        <td valign=top><b class=m><font color=#0000000>
ç¹ï¿½é«â中æââ¡çâ°Ë:</font></b></td>
       </tr>       <tr>
        <td bgcolor=white class=s><div style=padding:10px;>pick it</div></td>
       </tr>
       <tr>
        <td class=s><INPUT TYPE=HIDDEN NAME="q" VALUE="pick it"><input type="hidden" name="kls" value="0">
 <input type="hidden" name="ienc" value="utf8"><br>
 <input type=submit name=search value="Search the web with this text">
        </td>
       </tr>
</form>

the text in capital letters is the one i am dealing with(it's not like that in the site but i made it in capitals to understand it), i want to get it's value but i cant, how can i do that?

or any other way to get the value of this input?

EDIT: am i talking by myself?;;;

Edited by c4nm7
Link to comment
Share on other sites

I don't understand what you are trying to do but

#include <IE.au3>
$oIE = _IECreate ("http://www.altavista.com")
$oForm = _IEFormGetObjByName ($oIE, "mfrm")
$oQuery = _IEFormElementGetObjByName ($oForm, "q")
_IEFormElementSetValue ($oQuery, "TEST!")
well ive been away for a few minutes and FINALLY someone replied!!

back on the subject:

is that an example?, trust me i know a lot more about IE than you may be thinking!(no offense), the form is on another site

or better page of altavista, you are completely out of site(sight)

go here and make a random translation,submit the form and then you ll see the site im trying to get(it's the first input with the translation's result that i want to get it's value)

thanks for helping

EDIT: 100 views and only 3 person replied, cmon it's not THAT hard i guess!

Edited by c4nm7
Link to comment
Share on other sites

well ive been away for a few minutes and FINALLY someone replied!!

back on the subject:

is that an example?, trust me i know a lot more about IE than you may be thinking!(no offense), the form is on another site

or better page of altavista, you are completely out of site(sight)

go here and make a random translation,submit the form and then you ll see the site im trying to get(it's the first input with the translation's result that i want to get it's value)

thanks for helping

EDIT: 100 views and only 3 person replied, cmon it's not THAT hard i guess!

ok found the solution myself....

thanks for the help :rolleyes:

Link to comment
Share on other sites

COM objects are a special data-type. Collections are a special type of COM object that contain references to one or more related COM objects -- sharing something conceptually with arrays, but quite different. If you simply write out the contents of a COM object, you see what you call Greek, but it is actually the internal representation of the COM object data variant. COM objects really only make sense when accessing their defined properties and methods -- IE.au3 tries to simplify this for you, but perhaps you should study some of the MSDN documentation I point to in my sig to get a better idea of what is really happening.

From the conceptual confusion I've seen in some of your recent posts, I'd strongly suggest you work through a good number of the helpfile examples for the _IE functions... I put a lot of work into making them all standalone and fully functional and believe they are pretty instructional. On the other hand, you say you figured this one out at this point, so perhaps you are on your way.

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

COM objects are a special data-type. Collections are a special type of COM object that contain references to one or more related COM objects -- sharing something conceptually with arrays, but quite different. If you simply write out the contents of a COM object, you see what you call Greek, but it is actually the internal representation of the COM object data variant. COM objects really only make sense when accessing their defined properties and methods -- IE.au3 tries to simplify this for you, but perhaps you should study some of the MSDN documentation I point to in my sig to get a better idea of what is really happening.

From the conceptual confusion I've seen in some of your recent posts, I'd strongly suggest you work through a good number of the helpfile examples for the _IE functions... I put a lot of work into making them all standalone and fully functional and believe they are pretty instructional. On the other hand, you say you figured this one out at this point, so perhaps you are on your way.

Dale

ok im back, im nearly at the end of my program , i just have a final problem WHICH IS THE SAME AS BEFORE, grrrrrrrrrrrrrr, this worked for a split second and again i have the same problem

well this is the code:

$oFm = _IEFormGetCollection($oIE, 0)
;its ok until here
$referenc = $oFm.method
$lement =  _IEFormElementGetObjByName($referenc, "q")
;now the error, cant get the value...

i also tryied $lement = _IEFormElementGetObjByName($oFm, "q") but

it wont work again

please important help !!! im at the end ant it's 4:30 am in my country

so i would like to sleep :rambo: but i will not be able if this problem is not solved ;;;;;

DaleHohm i think that you are the most suitable person to advice me , can you?

EDIT:400 posts

EDIT 2: DaleHohm i was expecting your arrival cause as i meantioned you are the most suitable person to advice me,

dont tell me that you left now :rolleyes:

Edited by c4nm7
Link to comment
Share on other sites

The the page you are trying to using is static (the same each time you visit) you can access any form using _IEFormGetCollection with a 0-based index. Forms are numbered in source order from the HTML starting at 0.

If the page is dynamic (different each time you visit) you may need to loop through the forms looking for the one you want. You would also use _IEFormGetCollection, but without the index value and then loop through the collection looking for the one you want based on other attributes. See example below...

If what you are trying to do is get access to a Form Input object, you can also use _IETagNameGetCollection($oIE, "input") and either use an index value to get a single object or loop through the collection to fine what you want.

Here is an example of looping through a collection to get what you want:

#include IE.au3

$oIE = _IECreate("http://www.altavista.com")

$oForms = _IEFormGetCollection($oIE)

$found = False

For $oForm in $oForms
    ; make sure to use String() in case the form action is null to avoid erroneous matches
    If string($oForm.action) = "http://www.altavista.com/web/results" Then
        ; We found it and $oForm if our object reference!
        $found = True
        ExitLoop
NextoÝ÷ Ù.q©ÚÊ.±æ®¶­sdb7G&ærb33c¶ôf÷&ÒæÖWFöBÒgV÷C¶vWBgV÷C²FVà
or other properties to find what you are looking for.

Dale

Edit: code forrmat block typo

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

Link to comment
Share on other sites

The the page you are trying to using is static (the same each time you visit) you can access any form using _IEFormGetCollection with a 0-based index. Forms are numbered in source order from the HTML starting at 0.

If the page is dynamic (different each time you visit) you may need to loop through the forms looking for the one you want. You would also use _IEFormGetCollection, but without the index value and then loop through the collection looking for the one you want based on other attributes. See example below...

If what you are trying to do is get access to a Form Input object, you can also use _IETagNameGetCollection($oIE, "input") and either use an index value to get a single object or loop through the collection to fine what you want.

Here is an example of looping through a collection to get what you want:

#include IE.au3

$oIE = _IECreate("http://www.altavista.com")

$oForms = _IEFormGetCollection($oIE)

$found = False

For $oForm in $oForms
    ; make sure to use String() in case the form action is null to avoid erroneous matches
    If string($oForm.action) = "http://www.altavista.com/web/results" Then
        ; We found it and $oForm if our object reference!
        $found = True
        ExitLoop
NextoÝ÷ Ù.q©ÚÊ.±æ®¶­sdb7G&ærb33c¶ôf÷&ÒæÖWFöBÒgV÷C¶vWBgV÷C²FVà
or other properties to find what you are looking for.

Dale

Edit: code forrmat block typo

ok tag worked thanks!!
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...