Jump to content

Internet Explorer Automation UDF library


DaleHohm
 Share

Recommended Posts

Dale,

Is there a way to catch a navigation error. For example if the web page is not found and returns 404 how could i set an error?

on MSDN i read about a NavigateError Event, but i havent figured out how to implement it.

http://msdn.microsoft.com/library/default....netexplorer.asp

Take a look at the example in the help file for the function ObjEvent. This has an IE example handling other events.

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Link to comment
Share on other sites

I am new to using autoit, i am opening an explorer shell in a tab of a gui. I would like to communicate with this webpage...what am i doing wrong?

here is my code

#include <IE.au3>

$Tab=GUICtrlCreateTab (0,0, 1000,700)

$Tab0=GUICtrlCreateTabitem ("Database")

$oIE = ObjCreate("Shell.Explorer.2")

$GUIActiveX = GUICtrlCreateObj($oIE, 10, 25, 900, 670)

GUICtrlSetStyle($oIE, $WS_VISIBLE)

$oIE.navigate("http://directbuy420.com/admin/admin/")

; get pointers to the login form and username and password fields

$o_form = _IEFormGetObjByName($oIE, "logoninfo")

$o_login = _IEFormElementGetObjByName($o_form, "username")

$o_password = _IEFormElementGetObjByName($o_form, "password")

; Set field values and submit the form

_IEFormElementSetValue($o_login, "blank")

_IEFormElementSetValue($o_password, "blank")

_IEFormSubmit($o_form)

Exit

I relize i may need to use the ie attach function, but a m not sure as to how to do that

any help would be greatly appreciated.

Note - If in attempting to help someone checks the page i am loading, i understand that the form names in the above code are incorrect.

Thank you in advance

Link to comment
Share on other sites

Hmm.. Would it be possible to turn all outputs from the IE off while launching an invisible IE-window? Like disabling all these Active X Errors and cookie verifiyng stuff.

I'm not really certain what what outputs you are referring to. The cookie varnings I know of are only there when you specifically configure IE to give them to you (Tools -> Internet Options -> Privacy -> Advanced...). I can't guess what ActiveX errors you are referring to.

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 am new to using autoit, i am opening an explorer shell in a tab of a gui. I would like to communicate with this webpage...what am i doing wrong?

Please refer to your duplicate post in V3 Support

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

hi,

I wonder whats wrong - I'm trying to fill in a "file string" in the formfield of www.Rapidshare.de.

But it doesn't work - the field stays empty.

Are there any special form fields (like FileFieds) I cannot fill in with the exlorer object?

Greetings

Mozart90

IE blocks scripting of <input tyle="file"> fields for security reasons. There is an example of using .focus and the AutoIt SEND command in reply 3 (the examples collection) of this post. It is the only workarond I know of.

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 got an error:

Line 776 (File "..\..\IE.au3)

If IsObj($o_object.elements) Then

If IsObj($o_object.e^ERROR)

Error: Unable to parse line

any idea why its happenning? i tried to run the hotmail login script...

Some prople have had trouble downloading the IE.au3 file properly -- try right-click and save target as... of it tries to load the file as text in your browser. If that is not it, make certain you are running a recent beta version 3.1.1.63 or higher (check the output from running the script to be certain).

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

See if this will get you started:

#include <IE.au3>; Include the UDF

; Create an IE Browser
;
$oIE = _IECreate()

; Navigate to your URL
;
_IENavigate($oIE, "http://pda.hko.gov.hk/wxreporte.htm")

; Get a reference to the Second table on the webpage (where the detail is stored)
;    note that object indexes are 0-based, so the second table is index 1
;
$oTable2 = _IETableGetObjByIndex($oIE, 1)

; Read the table cells into a 2-D array
;
$aWeather = _IETableWriteToArray($oTable2)

; Write the array contents out to the console
;
For $i = 0 to Ubound($aWeather, 2) - 1
    ConsoleWrite("City: " & $aWeather[0][$i] & " --> Temp: " & $aWeather[1][$i] & @CR)
Next

It creates output like this:

City: KING'S PARK --> Temp: 28 DEGREES;
City: WONG CHUK HANG --> Temp: 29 DEGREES;
City: TA KWU LING --> Temp: 29 DEGREES;
City: LAU FAU SHAN --> Temp: 28 DEGREES;
City: TAI PO --> Temp: 29 DEGREES;
City: SHA TIN --> Temp: 29 DEGREES;
City: TUEN MUN --> Temp: 29 DEGREES;
City: TSEUNG KWAN O --> Temp: 28 DEGREES;
City: SAI KUNG --> Temp: 29 DEGREES;
City: CHEUNG CHAU --> Temp: 28 DEGREES;
City: CHEK LAP KOK --> Temp: 30 DEGREES;
City: TSING YI --> Temp: 29 DEGREES;
City: SHEK KONG --> Temp: 29 DEGREES .

Dale

Edit: refromatted for easier reading

Can you show me how to put the output on a text file?
Link to comment
Share on other sites

Hello All,

Dale, this is great stuff...

How would I use a web browser control rather than Internet explorer to embed a browser window in an AutoIT application.

I am looking at writing a kiosk style app that I will need to control the browser from and limit the standard IE functionality to the end user.

I found on MSDN that the web browser control is component is part of Shdocvw.dll, and found the following example, but I have no Idea how to create the object?

Dim IE As SHDocVw.InternetExplorer

Set IE = CreateObject("InternetExplorer.Application")

Thanks,

billmez

Link to comment
Share on other sites

Can you show me how to put the output on a text file?

guayo, with 21+ pages of discussion pretty well focused on IE.au3, I respectfully ask that you take the question about writing array contents to a text file to the V3 Support Forum.

thanks,

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

Dale, this is great stuff...

How would I use a web browser control rather than Internet explorer to embed a browser window in an AutoIT application.

What you want is GUICtrlCreateObj() -- in fact the example in the helpfile for this does just what you want. Note that most of the IE.au3 functions will work on the embedded object, but the object model differes a bit (most of it makes sense -- things like there being no status bar in the embedded app for example).

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

What you want is GUICtrlCreateObj() -- in fact the example in the helpfile for this does just what you want. Note that most of the IE.au3 functions will work on the embedded object, but the object model differes a bit (most of it makes sense -- things like there being no status bar in the embedded app for example).

Dale

Thanks Dale, I'll give that a try.

[edit]

One other thing has come up. Using a function like _IEAction($oIE, "back") when there is not a previous page in the history, yeilds a fatal error like:

C:\Program Files\AutoIt3\beta\Include\ie.au3 (1265) : ==> The requested action with this object has failed.:

$o_object.GoBack ()

$o_object.GoBack ()^ ERROR

Is there a way to either trap these errors so they are not fatal, or check for a condition before calling the function to eliminate the problem? I imagine it would be the same with forward and some others also.

[/edit]

[edit2]

I found the answer to the above in a previous edit:

$oMyError = ObjEvent("AutoIt.Error", "_IEAction")

Will trap the error. Thanks again

[/edit2]

The only other question I have at this point is in reference to other browsers using IE control. I use Maxthon, and if I open a browser using IE.au3, it will open Maxthon since it is my default browser. Is there a way to circumvent this and open IE instead? Obviously it works fine if I set IE to the default browser, but the control for items like toolbar and addressbar won't work in Maxthon.

I guess this thread certainlly wins the popularity contest!

Bill

Edited by billmez
Link to comment
Share on other sites

[edit]

It seems to me that if we van figure out how to trap the document click events, we can also make a tabbed browser interface that opens windows in a new tab. All help with this would be appreciated.

[/edit]

I'm trying to trap the right click context menu of the document object. From MSDN reference on the document object using the IE.au3 function _IEDocumentGetObj, there is an event oncontextmenu.

Obviously the $oIE object has ben created and document loaded, but I can't seem to get it to react to the right click. Any ideas?

$objWin = _IEDocumentGetObj($oIE)
$oRc = ObjEvent($objWin, "_doNothing()", "oncontextmenu" )


[edit]
I also tried this which seems to be closer to the example for ObjEvent

$objWin = _IEDocumentGetObj($oIE)
$oRc = ObjEvent($objWin, "doNothing_", "oncontextmenu")

Func doNothing_oncontextmenu()
    MsgBox(0, "", "event fired")
    EndFunc
[/edit]
Edited by billmez
Link to comment
Share on other sites

Complete newbie question :lmao:

I create browser with

$o_IE=_IECreate ()
_IENavigate($o_IE, "http://mydomain.com")

Than I fill in the form with

$o_Form = _IEFormGetObjByName ($o_IE, "Index")
$o_username=_IEFormElementGetObjByName($o_Form,"USERNAME")
_IEFormElementSetValue($o_username, "real_username")
$o_password=_IEFormElementGetObjByName($o_Form,"PASSWORD")
_IEFormElementSetValue($o_password, "real_password")

But

_IEFormSubmit ($o_Form)

doesn't work

neither

$o_submit=_IEFormElementGetObjByName($o_Form, "BUTTON")
$o_submit.Click

neither

$o_submit = $o_IE.document.getElementById("BUTTON")
$o_submit.Click

Send ('{ENTER}')

though works well. It's Ok. Bu now the question. Which parameters I have to use for "ControlSend" instead of "Send"? Thank you.

Edited by APRES
Link to comment
Share on other sites

Complete newbie question :lmao:

I create browser with

$o_IE=_IECreate ()
_IENavigate($o_IE, "http://mydomain.com")

Than I fill in the form with

$o_Form = _IEFormGetObjByName ($o_IE, "Index")
$o_username=_IEFormElementGetObjByName($o_Form,"USERNAME")
_IEFormElementSetValue($o_username, "real_username")
$o_password=_IEFormElementGetObjByName($o_Form,"PASSWORD")
_IEFormElementSetValue($o_password, "real_password")

But

_IEFormSubmit ($o_Form)

doesn't work

neither

$o_submit=_IEFormElementGetObjByName($o_Form, "BUTTON")
$o_submit.Click

neither

$o_submit = $o_IE.document.getElementById("BUTTON")
$o_submit.Click

Send ('{ENTER}')

though works well. It's Ok. Bu now the question. Which parameters I have to use for "ControlSend" instead of "Send"? Thank you.

In my experience, there is no reason for the .click methods not to work for you as long as you have the correct button specified. It simulates the same action as you physically clicking on the button. All of your logic looks valid so long as you have the right "button" -- one thing that can make it tricky is if there is more than one object with that name...

Regarding ControlSend -- it does not in fact require a ControlID. You and leave it "" and simply send to the window. You'll want to do a .focus on the button first.

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

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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