Jump to content

_IEFormGetObjByName


 Share

Recommended Posts

Hi all,

I tried to get a form object with this script:

#include <IE.au3>
_IE_VersionInfo()

$oIE = _IECreate("www.google.pl")
_IELoadWait ($oIE)
$oForm = _IEFormGetObjByName ($oIE, "f")
$oQuery = _IEFormElementGetObjByName ($oForm, "q")
_IEFormElementSetValue ($oQuery, "test")

Everything was OK

Next I tried to do the same thing on different page that uses framese...

$oIE = _IECreate("www.ogame.pl")
_IELoadWait ($oIE)
$oForm = _IEFormGetObjByName ($oIE, "formular")
$oLogin = _IEFormElementGetObjByName ($oForm, "login")
_IEFormElementSetValue ($oLogin, "test")

This code gives me an output on console:

--> IE.au3 Information from function _IE_VersionInfo, version T2.0-5 (Release date: 20060703)
--> IE.au3 Warning from function _IEFormGetObjByName, $_IEStatus_NoMatch
--> IE.au3 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType
--> IE.au3 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType
>Exit code: 0   Time: 4.703

Can someone help me with this?

Link to comment
Share on other sites

If there are frames, you need to get a reference to the correct frame and then use it where you are using the $oIE reference in your previous example.

Please see the helpfile info on _IEFrame* functions.

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

I tried but this language is pretty new to me ;)

#include <IE.au3>
_IE_VersionInfo()
$oIE = _IECreate("www.ogame.pl")
_IELoadWait ($oIE)
$oFrames = _IEFrameGetCollection($oIE)
$iNumFrames = @extended
ConsoleWrite("Number of frames: " & $iNumFrames & @CR)
$oForms = _IEFormGetObjByName($oFrames, "formular")
$oLogin = _IEFormElementGetObjByName ($oForms, "login")
_IEFormElementSetValue ($oLogin, "test")

this gives me errors, too:

--> IE.au3 Information from function _IE_VersionInfo, version T2.0-5 (Release date: 20060703)
Number of frames: 1
C:\Program Files\AutoIt3\beta\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
>Exit code: 0   Time: 5.071

Problem is that I don;t know what to do with "$oFrames" ;/

Link to comment
Share on other sites

To get a reference to the first (and only) frame in this case, use:

$oFrame = _IEFrameGetCollection($oIE,0)

This gets a reference to the first frame in the collection by 0-based index.

Then use $oFrame (instead of $oFrames) in the later calls.

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

  • Moderators

If you don't specify the second parameter for _IEFrameGetCollection() it returns a collection object (I will explain more about that in a minute). In your case there is just one frame so you can get a reference to it like so...

Notice that I use "0" (zero) as the index number, this specifies the first frame as IE Objects are 0-based.

$oFrame = _IEFrameGetCollection($oIE, 0)oÝ÷ Ù8b²+-æÞ²×±¦V§jب(ºW_w_¢·(*'¡¸ÞrÛ*º^*%ç-èn7¶è¾'^±§(÷§éíÁ¬­¢·z»hj·¥j׺.¦âµé¬jƬx%zãyËSè­zk(­é^éí²)ÚreyËb¢yÞyÚ'&Þ­éZµç[ÊØ^}§-¶­¶²{¬¶)íç(W¶*'W¦z{l¡ö¢Y^rبÚ'¢ØZ½ëh²«zØ^±©u«Z·*^þ«¨µáÞ­è¬jw±jjezá£hºÇreyËb¢zç-¶¬)²Øk¢è!y§!~¶¦zãyËl­ën®x§+wöÉÚ殶­sbb33c¶ôg&ÖW2ÒôTg&ÖTvWD6öÆÆV7Föâb33c¶ôR¤f÷"b33c¶ôg&ÖRâb33c¶ôg&ÖW0 6öç6öÆUw&FRb33c¶ôg&ÖRäæÖRfײ5"¤æW@
Link to comment
Share on other sites

Here is an example of how to use a collection object, this loops through each frame objects returning it's name.

$oFrames = _IEFrameGetCollection($oIE)
For $oFrame In $oFrames
    ConsoleWrite($oFrame.Name & @CR)
NextoÝ÷ Ûú®¢×uÙr¶¬Ëk¹çè­©e¢Ø^­Ê%ç-ìp=7ëjg¬1 Ív.éí²Øb±«reyËb¢zç-_¢»(êÞjÊ'Êjyè¶Z(¦Øk¢è!ÙbëajÑޭ謶ũ©çë¢kaz¥¥ø¥y«­¢+Ø쨨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨(ìáµÁ±Ä´=Á¸ÉµÍÐáµÁ±°Ð½±±Ñ¥½¸½ÉµÌ(ì¹±½½ÀÑ¡É½Õ Ñ¡´¥ÍÁ±å¥¹Ñ¡¥ÈͽÕÉUI0ÌäíÌ(쨨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨(ì(¥¹±Õ±Ðí%¹ÔÌÐì(ÀÌØí½%ô}%}áµÁ± ÅÕ½ÐíɵÍÐÅÕ½Ðì¤(ÀÌØí½ÉµÌô}%ɵÑ
½±±Ñ¥½¸ ÀÌØí½%¤(ÀÌØí¥9յɵÌôáѹ)½ÈÀÌØí¤ôÀѼ ÀÌØí¥9յɵ̴Ĥ(ÀÌØí½Éµô}%ɵÑ
½±±Ñ¥½¸ ÀÌØí½%°ÀÌØí¤¤(5Í    ½à À°ÅÕ½Ðíɵ%¹¼ÅÕ½Ðì°}%AɽÁÉÑåÐ ÀÌØí½Éµ°ÅÕ½Ðí±½Ñ¥½¹ÕÉ°ÅÕ½Ð줤)9áÐ

Dale

p.s. big_daddy makes so few mistakes, go easy on him ;)

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

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...