Jump to content

Internet Explorer Automation UDF library


DaleHohm
 Share

Recommended Posts

Hello Whaouu,

This is strange because I created the framset here just as you have it defined and used your code and it worked without any trouble.

What version of AutoIt did you use? (it should show you just prior to the error message). What version of Windows? Is the machine or the device you are trying to control particularly slow perhaps?

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

Hello Whaouu,

This is strange because I created the framset here just as you have it defined and used your code and it worked without any trouble.

What version of AutoIt did you use? (it should show you just prior to the error message). What version of Windows? Is the machine or the device you are trying to control particularly slow perhaps?

Dale

Hello, Dale,

Thank you for your very fast answer!

My version of AutoIt is as follows: Beta v3.1.1.91

My version of Windows is : Windows XP Pro SP2.

The resource is local thus very fast, can too be ?

The menu posted in the frame is a cgi probably generated by an engine PHP. But even when I recover source HTML (after interpretation of the code) I have the same problem.

I tested my code with pages on Internet and your example of code and that functions perfectly.

I do not see from which come the problem. B)

Link to comment
Share on other sites

My version of AutoIt is as follows: Beta v3.1.1.91

My version of Windows is : Windows XP Pro SP2.

That is the same setup I have so I cannot explain your trouble. One possible issue might be a client or server-side redirect being performed in the menu.cgi page -- the idea being that the browser actually reports that the readyState of the embedded page is complete, but then it immediately starts loading another page and you are trying to access an element on this new page before it is complete.

Another place to investigate is that the readyState property of a frameset page is not supposed to go to 4 (complete) until all of the frame pages are also complete (readyState is what is checked by _IELoadWait - which is called by _IENavigate). You may want to toy with doing an _IELoadWait($o_Frame) and see if your results change.

Thsi feels like a timing issue caused by things you have not yet uncovered about how the page actually works, so trying some Sleep commands or _IELoadWait on the frames to help you work around whatever is happening to you.

Good luck,

Dale

Edit: 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

i am working on a web page that pulls an applet from microsoft

i cant get any info from AU3info and the scource does not show the html before or after the applet is loaded..

however, i notice at the bottom left of my IE, when i place the mouse over the on-screen button i wish to select, it says "Dock / Undock"

is thee a function you have that could interpret that...

and if so, could you maybe show me a small example of how i might approach this...

i have used you IE3 before... but i am lost this time

thanks

8)

NEWHeader1.png

Link to comment
Share on other sites

i am working on a web page that pulls an applet from microsoft

i cant get any info from AU3info and the scource does not show the html before or after the applet is loaded..

however, i notice at the bottom left of my IE, when i place the mouse over the on-screen button i wish to select, it says "Dock / Undock"

is thee a function you have that could interpret that...

and if so, could you maybe show me a small example of how i might approach this...

i have used you IE3 before... but i am lost this time

thanks

8)

Even if "View Source" has been disabled you should still be able to retrieve it in one of these two methods:

For just the Body HTML:

$sBody = _IEBodyReadHTML($oIE)

or for the entire page including HEAD with java script:

$sHTML = $oIE.document.getElementsByTagName("HTML").item(0).outerHTML

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

Another place to investigate is that the readyState property of a frameset page is not supposed to go to 4 (complete) until all of the frame pages are also complete (readyState is what is checked by _IELoadWait - which is called by _IENavigate). You may want to toy with doing an _IELoadWait($o_Frame) and see if your results change.

Hello Dale,

Thank you very much for your answer!

I think that it is a problem speed.

I made the following test:

I captured the pages of the site which you use in example for the frames (http://www.cs.princeton.edu/~kguinee/thesis.html). I installed these pages on a local server (linux Red Hat).

I launch connection with your example on the distant server (http://www.cs.princeton.edu/~kguinee/thesis.html), is good.

I launch connection with your example on the local server (http://192.168.1.10/thesis.html), is not good.

I tried to put temporizations, but obviously that does not change the problem.

But it is probable that I do not do that correctly. :P

Edited by Whaouu
Link to comment
Share on other sites

I tried to put temporizations, but obviously that does not change the problem.

But it is probable that I do not do that correctly. :P

I can no longer find the reference that indicated to me that readyState for the top-level document would not be set to complete prior to all of the child frames being set to complete. I'm no longer certain that this is true.

Therefore, I suggest that you perform an explicity _IELoadWait() test on the frames you are trying to access before relying on their content.

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 made a minor alteration to the _IELoadWait() function, to have a time out period. Sometimes the page won't load (Still laoding an image or what not), so I found this to help.

;===============================================================================
;
; Function Name:    _IELoadWait()
; Description:      Wait for a browser page load to complete before returning
; Parameter(s):     $o_object   - InternetExplorer.Application object
;                   $i_delay    - wait this many milliseconds before checking status
; Requirement(s):   AutoIt3 Beta with COM support (post 3.1.1)
; Return Value(s):  On Success  - Returns an object variable pointing to
;                  On Failure   - 0  and sets @ERROR = 1
; Author(s):        Dale Hohm
;
;===============================================================================
;
Func _IELoadWait($o_object, $i_delay = 1000, $i_timeout = 30000)
    If IsObj($o_object) Then
        $timedout = False
        $time = 0
        $s_oname = ObjName($o_object)
        Sleep($i_delay)
        While ($o_object.document.readyState <> "complete") and ($o_object.document.readyState <> 4) and $timedout = False
            Sleep(100)
            If $i_timeout > 0 Then
                $time = $time + 100
                If $time >= $i_timeout Then
                    SetError(1)
                    Return 0
                EndIf
            EndIf
        WEnd
        SetError(0)
        Return 1
    Else
        SetError(1)
        Return 0
    EndIf
EndFunc  ;==>_IELoadWait

Other than that, everything else works great!

Link to comment
Share on other sites

I made a minor alteration to the _IELoadWait() function, to have a time out period. Sometimes the page won't load (Still laoding an image or what not), so I found this to help.

Thanks -- and yes that is a recognized deficiency in T1.4

I have an implementation of this timeout in the next release but the timeout value is implemented with a global variable rather than a parameter because there are several routines that call _IELoadWait() behind the scenes and I don't want to have to add another parameter to each of those routines as well.

Glad all else is working for you :P

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

Thanks -- and yes that is a recognized deficiency in T1.4

I have an implementation of this timeout in the next release but the timeout value is implemented with a global variable rather than a parameter because there are several routines that call _IELoadWait() behind the scenes and I don't want to have to add another parameter to each of those routines as well.

Glad all else is working for you :P

Well by the timeout being '$i_timeout = 30000' by default, I haven't had any issues. I know the _IENavigate, etc uses the _IELoadWait, and it still works fine. What would be different by using a global variable?

If there was a way to know what exactly was waiting to be "complete", that would be awesome. As I understand it, the actual HTML loads first, then everything else (Images, Flash, Embeded Media, etc.). If there was a way to know that the HTML was fully loaded, and not care about anything else, and consider it "complete", that would be best for how I am using it.

Is that possible?

Edited by AcidicChip
Link to comment
Share on other sites

Well by the timeout being '$i_timeout = 30000' by default, I haven't had any issues. I know the _IENavigate, etc uses the _IELoadWait, and it still works fine. What would be different by using a global variable?

If there was a way to know what exactly was waiting to be "complete", that would be awesome. As I understand it, the actual HTML loads first, then everything else (Images, Flash, Embeded Media, etc.). If there was a way to know that the HTML was fully loaded, and not care about anything else, and consider it "complete", that would be best for how I am using it.

Is that possible?

The global variable would allow changing the timeout value for all occurances of _IELoadWait without needing to add an optional parameter to all other functions that use it. It could easily be changed if to a value of anyone's liking rather than choosing a static value like the 30 seconds you suggest.

The object ReadyState property used by _IELoadWait() can have 5 different values:

0 | uninitialized - Object is not initialized with data.

1 | loading - Object is loading its data.

2 | loaded - Object has finished loading its data.

3 | interactive - User can interact with the object even though it is not fully loaded.

4 | complete - Object is completely initialized.

_IELoadWait() will only return success once the value is 4 or complete. You may find that you can start working with the document successfully once it reaches 3 or interactive (this is when the scroll bars work and you can click on links etc. -- I don't have good definitions of the loading and loaded states). If you wanted to do this you could create your own LoadWait by querying the readystate status with _IEGetProperty($o_object, "readystate").

One last thing to point out is that the readystate property applies to nearly any object in the DOM. So you can actually use _IEGetProperty($o_object, "readystate") where $o_object is a table object reference for example.

Hope this helps.

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 can no longer find the reference that indicated to me that readyState for the top-level document would not be set to complete prior to all of the child frames being set to complete. I'm no longer certain that this is true.

Therefore, I suggest that you perform an explicity _IELoadWait() test on the frames you are trying to access before relying on their content.

Dale

Hello Dale,

I tested as you suggest it to me putting a temporization on the loading of the frame, but I have an error on my local copy of the site (http://www.cs.princeton.edu/~kguinee/thesis.html).

Sample code :

...
$o_Frame = _IEFrameGetObjByIndex($o_IE, 1)
_IELoadWait($o_Frame)
_IEClickLinkByIndex($o_Frame, 1, 1)
...

When I use the same code for connection to the distant site, it functions perfectly.

The error message :

Line 1236

While($o_object.document.readyState <> "complete") and ($o_object.document.readyState <> 4)

While($o_object.document^ERROR

Error: The requested action whith this object has failed.

I do not know if that can help where gives an idea? :P
Link to comment
Share on other sites

Whaouu,

I'd like you to do a test for me please. Please perform the following edit in the _IELoadWait() routine near the bottom of IE.au3:

Replace this line:

        While ($o_object.document.readyState <> "complete") and ($o_object.document.readyState <> 4)

With this one:

        While ($o_object.readyState <> "complete") and ($o_object.readyState <> 4)

This will monitor the readystate of the next higher level object (typically a 'window' object) instead of the document. For some reason the embedded document object in your local frame is not being instantiated prior to the readystate check. If this works properly it may be a better way to do this in IE.au3 in the future. It will also make the _IELoadWait routine more generic such that it can be used with other objects such as forms and tables.

RSVP,

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'd like you to do a test for me please. Please perform the following edit in the _IELoadWait() routine near the bottom of IE.au3:

I make the test with pleasure. :lmao:

Func _IELoadWait($o_object, $i_delay = 0)
    If IsObj($o_object) Then
        $s_oname = ObjName($o_object)
        Sleep($i_delay)
        While ($o_object.readyState <> "complete") and ($o_object.readyState <> 4)
            Sleep(100)
        WEnd
        SetError(0)
        Return 1
    Else
        SetError(1)
        Return 0
    EndIf
EndFunc  ;==>_IELoadWait

I tested with the page on the distant server and the local server, and I have an error on both.

Line 1236

While ($o_object.readyState <> "complete") and ($o_object.readyState <> 4)

While ($o_object.readyState^ERROR

Error: The requested action whith this object has failed.

To afflict for the bad news. :P
Link to comment
Share on other sites

I tested with the page on the distant server and the local server, and I have an error on both.

To afflict for the bad news. :P

Thanks for testing. Sorry for the failure -- MSDN shows that FRAME and IFRAME support the readyState property but in fact they do not.

One for test please.

Leaving the _IELoadWait() with the change I requested above, please add this wait to your code that will test the readyState of the browser overall instead of the frame:

_IELoadWait($o_IE)

If this fixes your problem it should indicate that the readyState bubbles to the top of the browser instance...

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

Hi,

I would like to click on a specific checkbox but they all have the same name in the html code

Ex:

<input type="checkbox" name="lot" value="FNF49001F7%%01%%55%% %% %%BRSCOVER%%0000040N4445" id="FNF49001F7%%01%%55%% %% %%BRSCOVER%%0000040N4445"/>

<input type="checkbox" name="lot" value="ADF490005Q%%01%%48%% %% %%BRSCOVER%%0000P98P2403" id="ADF490005Q%%01%%48%% %% %%BRSCOVER%%0000P98P2403"/>

Only the value and ID change.

When i do:

$o_form = _IEFormGetObjByName($oBrowser, "waitingLots")

$o_SubmitButton = _IEFormElementGetObjByName($o_form, "lot")

$o_SubmitButton.click

the first checkbox is check

How can I check a specific checkbox when they all have the same name?

Thanks!

Link to comment
Share on other sites

Hi,

I would like to click on a specific checkbox but they all have the same name in the html code

Ex:

<input type="checkbox" name="lot" value="FNF49001F7%%01%%55%% %% %%BRSCOVER%%0000040N4445" id="FNF49001F7%%01%%55%% %% %%BRSCOVER%%0000040N4445"/>

<input type="checkbox" name="lot" value="ADF490005Q%%01%%48%% %% %%BRSCOVER%%0000P98P2403" id="ADF490005Q%%01%%48%% %% %%BRSCOVER%%0000P98P2403"/>

Only the value and ID change.

When i do:

$o_form = _IEFormGetObjByName($oBrowser, "waitingLots")

$o_SubmitButton = _IEFormElementGetObjByName($o_form, "lot")

$o_SubmitButton.click

the first checkbox is check

How can I check a specific checkbox when they all have the same name?

Thanks!

_IEFormElementGetObjByName() takes an optional Index parameter: _IEFormElementGetObjByName($o_object, $s_name, $i_index = 0)

So in your case, you code insure the second checkbox was checked with the following code:

$o_form = _IEFormGetObjByName($oBrowser, "waitingLots")
$o_CheckBox2 = _IEFormElementGetObjByName($o_form, "lot", 1); index is 0-based
$o_CheckBox2.checked = True

You can toggle the check status with .click (i.e. check if unchecked, uncheck if checked)

You can test whether it is checked by evaluating whether $o_CheckBox2.checked is True|False

Note that the "value" of a checkbox is not whether it is checked or not, but rather the value sent back with the from data if it IS checked.

hope this helps,

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

Leaving the _IELoadWait() with the change I requested above, please add this wait to your code that will test the readyState of the browser overall instead of the frame:

_IELoadWait($o_IE)

If this fixes your problem it should indicate that the readyState bubbles to the top of the browser instance.

Hello Dale,

Thank you for your answer.

I proceeded to the update of my version which is now : v3.1.1.95

#include <IE.au3>
$o_IE = _IECreate()
;$var = _IENavigate($o_IE, "http://www.cs.princeton.edu/~kguinee/thesis.html", 1)
$var = _IENavigate($o_IE, "http://192.168.1.12/thesis.html", 1)
$o_Frame = _IEFrameGetObjByIndex($o_IE, 1)
_IELoadWait($o_IE)
sleep (5000)
_IEClickLinkByIndex($o_Frame, 1, 1)

I carried out the test, but the problem persists on the local copy of the site. I added a temporization of 5 second additional as you can see it on the code.

Here is the error message:

Line 570

$doc = $o_object.document

$doc = $o_object.document^ERROR

Error: The requested action whith this object has failed.

I wonder whether the problem is really on the level of temporization. If it is the case the deadlines of 5 seconds to him only should be enough if it is the case ? :P
Link to comment
Share on other sites

hi dale, nice work.... now i can automate my ie browser, but i got some problem..

how about if there is existing internet explorer and i want to enter a text then click enter.

i your code you always open a IE browser.

how about this scenario.

example.

i have already open a browser and url is google.com

and i only want to automate enter a text that i want to search then click google search.

no more opening additional browser.

thanks in advance.

julius

-----------------------------------------------------------BSECE, MCPAIM: juliusrmsYM: jivy_21@yahoo.comMSN: juliusLramos@hotmail.comMobile #: (Globe): +639167031989Web: http://www.trendmicro.com

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...