Jump to content

IEFormElementGetCollection does not return type imaage


Recommended Posts

I have a problem with a function belong to IE.au3 UDF, _IEFormElementGetCollection.

the issue is that IEFormElementGetCollection does not find the image element. why?

can you please help?

Beside, I would like to know if someone before implemented a small application with the following features.

1) Grab all forms and forms's elements and attributes on any web page

2) The information that was collected can be used to send post and get requests no matter what url was typed.

Thanks!

Please see this example

#include <IE.au3>

$oIE = _IE_Example("form")
$forms_get = _IEFormGetCollection($oIE)
$i = 0
For $oForm In $forms_get
    $form_get = _IEFormGetCollection($oIE, $i)
    $elements_get = _IEFormElementGetCollection($form_get)
        $j = 0
        For $oElement In $elements_get
            ConsoleWrite($i & "-" & $j & ":  " & $oElement.name & ", " & $oElement.type & ", " & $oElement.id & ", " & $oElement.value & @LF)
            $j += 1
        Next
        $i += 1
Next
Edited by lsakizada

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

I think there's a different function for IMG tags... _IEImgGetCollection() ?

Sorry don't know about your second question.

Nop..this is not working. It does not display the <Input type'image' > tag

check this..

#include <IE.au3>
;$oIE = _IECreate ("http://www.autoitscript.com/")
$oIE = _IE_Example("form")
$oImgs = _IEImgGetCollection ($oIE)
$iNumImg = @extended
MsgBox(0, "Img Info", "There are " & $iNumImg & " images on the page")
For $oImg In $oImgs
    MsgBox(0, "Img Info", "src=" & $oImg.src)
Next
 exit

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

Try this:

#include <IE.au3>

$oIE = _IE_Example("form")
$forms_get = _IEFormGetCollection($oIE)
$i = 0
For $oForm In $forms_get
    $form_get = _IEFormGetCollection($oIE, $i)
    $elements_get = _IETagNameGetCollection($form_get, "input")
        $j = 0
        For $oElement In $elements_get
            If $oElement.type & "" = "image" Then ConsoleWrite($i & "-" & $j & ":  " & $oElement.name & ", " & $oElement.type & ", " & $oElement.id & ", " & $oElement.value & @LF)
            $j += 1
        Next
        $i += 1
Next

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Try this:

#include <IE.au3>

$oIE = _IE_Example("form")
$forms_get = _IEFormGetCollection($oIE)
$i = 0
For $oForm In $forms_get
    $form_get = _IEFormGetCollection($oIE, $i)
    $elements_get = _IETagNameGetCollection($form_get, "input")
        $j = 0
        For $oElement In $elements_get
            If $oElement.type & "" = "image" Then ConsoleWrite($i & "-" & $j & ":  " & $oElement.name & ", " & $oElement.type & ", " & $oElement.id & ", " & $oElement.value & @LF)
            $j += 1
        Next
        $i += 1
Next

:)

Hi PsaltyDS,

Its honor for me to get reply from you ;)

I know that the _IETagNameGetCollection function can return the image one.

But I wonder why to go with two loops. Is this a bug of microsoft or IE.au3?

The same can be done with this code..

$oInputs = _IETagNameGetCollection($oIE, "Input")
For $oInput In $oInputs
if $oInput.type = "image" then
        ConsoleWrite( $oInput.form.name  & " ," & $oInput.form.id & ", " & $oInput.name & ", " & $oInput.type & @CRLF)
endif
Next

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

See _IEFormImageClick - it should offer you a solution and also gives you an explanation.

type=image was introduced into HTML much later and I think they did this to prevent a new element entering the collection from breaking existing code.

Dale

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

But I wonder why to go with two loops. Is this a bug of microsoft or IE.au3?

Your original post included the loop for all forms, that's the only reason it's there in my example. How far you have to drill down into frames/forms/etc. before searching for your element will be different in each case. It is unrelated to the actual issue (as Dale explained).

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...