Sign in to follow this  
Followers 0
dufran3

IE help

26 posts in this topic

Trying to use the IE.au3 function with some code. I am trying to do a couple of things. I will use google as an example. Google has a "edit" input box field. When using AutoIt's window, I cannot find a classname to refrence when using "ControlSetText" I have only been able to use the "Send" command to send "tabs" and such. That isn't very reliable. Any idea how I specifically enter text into a input control like that? Also, I am trying to use the _IELinkGetCollection function to get a list of all the functions, because my _IELinkClickByText function isn't working right. I wanted to get a list of all the links on the page. However when I msgbox it out, it is cryptic characters...what am I doing wrong????

Thanks

$main = _IECreate('http://www.google.com')
    $links = _IELinkGetCollection($main)
    msgbox(0,'',$links)

Share this post


Link to post
Share on other sites



Trying to use the IE.au3 function with some code. I am trying to do a couple of things. I will use google as an example. Google has a "edit" input box field. When using AutoIt's window, I cannot find a classname to refrence when using "ControlSetText" I have only been able to use the "Send" command to send "tabs" and such. That isn't very reliable. Any idea how I specifically enter text into a input control like that? Also, I am trying to use the _IELinkGetCollection function to get a list of all the functions, because my _IELinkClickByText function isn't working right. I wanted to get a list of all the links on the page. However when I msgbox it out, it is cryptic characters...what am I doing wrong????

Thanks

$main = _IECreate('http://www.google.com')
    $links = _IELinkGetCollection($main)
    msgbox(0,'',$links)oÝ÷ Ûú®¢×êÞëÚÚZ®Ú¶¬¢êÜz+¡×ºÒ)éºÙÆW§Ø

:rolleyes:


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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

you are pwn, that did work for me...however...I tried using the same syntax to click the submit button...no dice...

;Login Button
$oLoginBtn = _IEGetObjByName($oIE, 'btnLogin')
_IEFormSubmit($oIE)oÝ÷ ÛMúnÙË¢§Ëazv¦y«,  ÞvÚ-ë.nh­nëm¢z'¶°y»"µâ7öghx-+(Gb´:'ßÛr¢èZµì!z|¨ºÇ­È_¢½ô)Ûyú+$x-éÚ²F§uø§v+m+ÛazÚârB!j÷¦¢·ª¹ë-ìiº.¶X§Æî´"Û§¶)m¢j+®¢»ajÐèmÁ©í¶îØ^ée¢ëh*.ì¬N¬v'mëkɺÚ"µÍÌÍÛÓÙÚ[HÒQQÙ]ØS[YJ   ÌÍÛÒQK  ÌÎNØÙÚ[ÌÎNÊBÒQPXÝ[Û
    ÌÍÛÓÙÚ[   ][ÝØÛXÚÉ][ÝÊ
Edited by dufran3

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I lied....using this piece of code to click on a link...

IELinkClickByText($oIE,'Edit',1)oÝ÷ Ù8^íéÞÆÚZè·ökkÊ)à¶%É(Øb±«­¢+Ù}%1¥¹­
±¥­  åQáÐ ÀÌØí½%°ÌäíàÄÄ´åÐÌÁ´ÀÀÌäì

Below is the snippet for both of them.

<a title="Click here to update License information." href='GenKey.aspx?pid=2244&lid=15260&sid=735'>
                                        Edit</a>




<a title="Click here to update License information." href='GenKey.aspx?pid=2244&lid=15260&sid=735'>
                                        f811-9f430a-00
                                    </a>&nbsp;

It will click on the first one, but not the second, I'm not sure why...

I'm getting this error in console:

--> IE.au3 Warning from function _IELinkClickByText, $_IEStatus_NoMatch

sounds like it isn't finding the f811-9f430a-00 text, even though i can clearly see it in source...:-(

Edited by dufran3

Share this post


Link to post
Share on other sites

RAWWWRRRRRRRRRR There is an invisible flippin space!!!!!!!!!!!!!!

This worked....

_IELinkClickByText($oIE,'f811-9f430a-00 ')oÝ÷ ØpY^Û©$x%G­+ºÚ"µÍÒQS[ÐÛXÚÐU^
    ÌÍÛÒQK  ÌÍÔÞÝ[RY   [È ÌÎNÈ ÌÎNÊ

argg!

Share this post


Link to post
Share on other sites

I will try and make this my last question. Sorry, I am new to IE.au3 and am just trying to understand how the functions work. i am new to AutoIt Scene just in general. Here is my other question. I am trying to get some text from a site out of a table. The table has 5 rows, I need the info out of row 3 which states "Product Key | ALLKJDJKRANDOM" The pipe is showing that the table is in 2 columns. The Product key is at random, and therefore I need to fine the Product key text, and the associated key. Here is the HTML from the site.

<TR>
                        <TD style="WIDTH: 122px">Product Key:</TD>
                        <TD>
                            <span id="lblKey">ALLKJDJKRANDOM</span></TD>
                    </TR>

I thought I would be able to use _IEAction with the copy command, but I"m not sure how that would work by finding the 2 items in that row... I also thought some of these functions would get the job done...but I'm not really sure of the syntax or which would be best. Can someone help me out???

-Functions I thought might do the trick...

_IETableWriteToArray()

_IETableGetCollection()

_IEDocReadHTML()

_IEBodyReadText()

I've tried using the "GetCollection" functions but have had problems every time with those....please help....again, sorry for my n00bness...

Share this post


Link to post
Share on other sites

I am trying to get some text from a site out of a table. The table has 5 rows, I need the info out of row 3 which states "Product Key | ALLKJDJKRANDOM" The pipe is showing that the table is in 2 columns. The Product key is at random, and therefore I need to fine the Product key text, and the associated key. Here is the HTML from the site.

I thought I would be able to use _IEAction with the copy command, but I"m not sure how that would work by finding the 2 items in that row... I also thought some of these functions would get the job done...but I'm not really sure of the syntax or which would be best. Can someone help me out???

-Functions I thought might do the trick...

_IETableWriteToArray()

_IETableGetCollection()

_IEDocReadHTML()

_IEBodyReadText()

I've tried using the "GetCollection" functions but have had problems every time with those.

This will at least display all the tables on the page:

$colTables = _IETableGetCollection($oIE)
$iCnt = @extended
If IsObj($colTables) Then 
    MsgBox(64, "Debug", "Ubound = " & UBound($colTables) & "  $iCnt = " & $iCnt)
    $n = 0
    For $oTable In $colTables
        _ArrayDisplay(_IETableWriteToArray($oTable), "Table: " & $n)
        $n += 1
    Next
Else
    MsgBox(16, "Error", "$colTables is not an object.")
EndIf

Hope that helps.

:rolleyes:


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

Share this post


Link to post
Share on other sites

Getting an error with that, I am using the exact code...I will paste below to ensure.

$colTables = _IETableGetCollection($oIE)
$iCnt = @extended
If IsObj($colTables) Then 
    MsgBox(64, "Debug", "Ubound = " & UBound($colTables) & "  $iCnt = " & $iCnt)
    $n = 0
    For $oTable In $colTables
        _ArrayDisplay(_IETableWriteToArray($oTable), "Table: " & $n)
        $n += 1
    Next
Else
    MsgBox(16, "Error", "$colTables is not an object.")
EndIf

I get this error:

testing.au3 (136) : ==> Expected a variable in user function call.:

_ArrayDisplay(_IETableWriteToArray($oTable), "Table: " & $n)

_ArrayDisplay(^ ERROR

Share this post


Link to post
Share on other sites

The error states it's expecting a variable, not a function. Without looking at anything, just changing that _ArrayDisplay:

For $oTable In $colTables
        $tableArray = _IETableWriteToArray($oTable)
        _ArrayDisplay($tableArray, "Table: " & $n)
        $n += 1
    Next

Hope that helps.


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

huh, now getting an error from the array.au3 include file:

Code:

For $oTable In $colTables
$tableArray = _IETableWriteToArray($oTable)
_ArrayDisplay($tableArray, "Table: " & $n)
$n += 1
Next

Error:

C:\Program Files\AutoIt3\Include\Array.au3 (175) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$sMsg = $sMsg & "[" & $iCounter & "] = " & StringStripCR($avArray[$iCounter]) & @CR

$sMsg = $sMsg & "[" & $iCounter & "] = " & StringStripCR(^ ERROR

>Exit code: 0 Time: 20.059

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Take what the error message says, and use that info...

It says the subscript range is incorrect, ie. you are trying to use an array element that exceeds the array boundaries.

Example:

$myarray[0]

$myarray[1]

If you try and call $myarray[2], you will get this error. Now see if you can apply this to your situation.

Edited by mikehunt114

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

Does it have anything to do with this?

$colTables = _IETableGetCollection($oIE)
$iCnt = @extended
If IsObj($colTables) Then 
MsgBox(64, "Debug", "Ubound = " & UBound($colTables) & "  $iCnt = " & $iCnt)

When the MsgBox comes up, it says Ubound = 0 and $iCnt = 2...could the ubound = 0 be the problem??

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

A collection object, like that returned from _IETableGetCollection, is not the same as an array. I'm not entirely clear about them myself, but I know that you cannot use normal methods to grab the elements from a collection object. That UBound isn't of any use to you anyways. The previous code was already handling the "enumeration" of the collection object, that UBound was unnecessary.

#include <IE.au3>
#include <Array.au3>

$oIE = _IECreate("www.msn.com", 1)


$colTables = _IETableGetCollection($oIE)
$iCnt = @extended
If IsObj($colTables) Then 
    MsgBox(64, "Debug", "Number of tables found: " & $iCnt)
    $n = 0
    For $oTable In $colTables
        $tableArray = _IETableWriteToArray($oTable)
        ;ConsoleWrite($oTable.document.body.innerText)
        _ArrayDisplay($tableArray, "Table: " & $n)
        $n += 1
    Next
Else
    MsgBox(16, "Error", "$colTables is not an object.")
EndIfoÝ÷ Ù±ßÛ!ü¨¹ªÞºÈ§j+zØZÞµ¦åyúèØ^reyËb¢yÉ·¬¢g­)à)¶¬Æ©¦º)®&­y«­¢+ؽÈÀÌØí½Q±%¸ÀÌØí½±Q±Ì($%ÍÍ¥¸ ÅÕ½ÐíѱÉÉäÅÕ½ÐìµÀìÀÌØí¸°}%Q±]É¥ÑQ½ÉÉä ÀÌØí½Q±¤¤(í}ÉÉå¥ÍÁ±ä ÀÌØíѱÉÉä°ÅÕ½ÐíQ±èÅÕ½ÐìµÀìÀÌØí¸¤(ÀÌØí¸¬ôÄ(9á

In the other code, $tableArray was being reassigned to each new table as the script progessed through.

Edited by mikehunt114

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

#15 ·  Posted (edited)

Was using an old version of array.au3, that's why I was getting errors.

So, I used your snippet, and it says there are 2 tables, the first table contains the info I need, the second table is nothing.

So, the table that I need the info from, is "table 0". I needto get the information from Row 0, Column 2.... :-(

Tried Msgbox(0,'',$tableArray[0][0]) and so on, but that didn't work. Trying to see if that information from the table was assigned to an element in the array. But I don't see it....hrmmm...

Edited by dufran3

Share this post


Link to post
Share on other sites

Was using an old version of array.au3, that's why I was getting errors.

So, I used your snippet, and it says there are 2 tables, the first table contains the info I need, the second table is nothing.

So, the table that I need the info from, is "table 0". I needto get the information from Row 0, Column 2.... :-(

@mikehunt114: I ran that code on a live site with 10 tables in the main page. Works fine to pass the results of a function that returns an array directly into _ArrayDisply() if you have the current production version of AutoIt.

@dufran3: Now that you know what you want, go get it:

$oTable = _IETableGetCollection($oIE, 0)
If IsObj($oTable) Then
    $avTable = _IETableWriteToArray($oTable)
    MsgBox(64, "Results", "Table: 0, Row: 0, Col: 2 = " & $avTable[0][2])
Else
    MsgBox(16, "Error", "$oTable is not an object.")
EndIf

Works for me...

:rolleyes:


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

Share this post


Link to post
Share on other sites

The array itself can be handled just like a usual array. It's the collection object that has to be handled differently. Hopefully the below can clarify things:

#include <IE.au3>
#include <Array.au3>

$oIE = _IECreate("www.msn.com", 1)

$colTables = _IETableGetCollection($oIE)
$iCnt = @extended
If IsObj($colTables) Then 
   MsgBox(64, "Debug", "Number of tables found: " & $iCnt)
    $n = 0
    For $oTable In $colTables
        $tableArray = _IETableWriteToArray($oTable)
        Assign("tableArray" & $n, $tableArray)
        _ArrayDisplay($tableArray, "Table: " & $n)
        $n += 1
    Next
Else
    MsgBox(16, "Error", "$colTables is not an object.")
EndIf


;Use an Eval() to get the values of $tableArray0, $tableArray1, etc.

You can use the For...In...Next loop to run through the collection object's elements. As for the actual array, that would be concerning $tableArray0, $tableArray1, etc. You can manipulate these just like regular arrays. I'd try and explain more, but I have to run, sorry.


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

#18 ·  Posted (edited)

I was able to msg box out the field that I needed. Still getting 1 error.

$colTables = _IETableGetCollection($oIE)
$iCnt = @extended
If IsObj($colTables) Then 
$n = 0
  For $oTable In $colTables
$tableArray = _IETableWriteToArray($oTable)
$n += 1
MsgBox(64, "Results", "Table: 0, Row: 0, Col: 2 = " & $tablearray[0][2])
GLOBAL $oProductKey = $tableArray[0][2]
  Next
Else
MsgBox(16, "Error", "$colTables is not an object.")
EndIf
EndFunc

Error is:

testing.au3 (139) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

GLOBAL $oProductKey = $tableArray[1][2]

GLOBAL $oProductKey = ^ ERROR

When I get the Msgbox with the "oProductKey" it gives me exactly the information i need. It seems like maybe the "for...next" loop is looping through 1 more time than needed? not sure what I need to change to get rid of that error message

Edited by dufran3

Share this post


Link to post
Share on other sites

I was able to msg box out the field that I needed. Still getting 1 error.

$colTables = _IETableGetCollection($oIE)
$iCnt = @extended
If IsObj($colTables) Then 
$n = 0
  For $oTable In $colTables
$tableArray = _IETableWriteToArray($oTable)
$n += 1
MsgBox(64, "Results", "Table: 0, Row: 0, Col: 2 = " & $tablearray[0][2])
GLOBAL $oProductKey = $tableArray[0][2]
  Next
Else
MsgBox(16, "Error", "$colTables is not an object.")
EndIf
EndFunc

Notice how the row/col you see in the HTML table is backwards in the AutoIt array that gets created. I had not noticed that before...

So if you look at the HTML table and say "I need row 0 column 2" you probably mean "top-most horizontal row, third cell from the left". AutoIt arrays are usually used by convention with $avArray[$row][$col], but it appears that the function _IETableWriteToArray() produces the array as [$col][$row]! :rambo:

So to get row 0 col 2 you might have to access the array with [2][0]. That almost looks like a bug to me, but I am too nooby with IE.au3 to know.

:rolleyes:


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

Share this post


Link to post
Share on other sites

I created a new script using your example code and it worked fine. The thing is, in my code, the [$row][$col] that I have assigned is giving me the correct info when msgBox the field out. Do you see any flaw in the code?

$colTables = _IETableGetCollection($oIE)
    $iCnt = @extended
    If IsObj($colTables) Then 
        ;$n = 0
        For $oTable In $colTables
            $tableArray = _IETableWriteToArray($oTable)
            ;$n += 1
            MsgBox(64, "Results", "Table: 0, Row: 1, Col: 2 = " & $tablearray[1][2])
            GLOBAL $oProductKey = $tableArray[1][2]
        Next
    Else
        MsgBox(16, "Error", "$colTables is not an object.")
    EndIf

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