Jump to content

Internet Explorer Automation UDF library


DaleHohm
 Share

Recommended Posts

I gave that code a try, it bombed, I don't get an error everytime with my original code, the problem I think now is that when I still have a session up and try to login with the script I am automatically forwarded to a page that does not contain any forms. So I think that when it tries to run...

For $form in $forms
            $fes = _IEFormElementGetCollection($form)
            For $fe in $fes
                if StringInStr($fe.name, "password") then
                    $passwordField = $fe.name
                endIf
            Next
        Next

It pukes because there are no forms. I have been trying to insert a conditional to ignore that part if there are no forms but I havn't had any success yet.

Link to comment
Share on other sites

Sorry, I should have read my own code before replying. Your code was in fact structured properly and your diagnosis of the issue sounds reasonable.

In order to have you code survive a COM error (like refereincing an object taht doesn't exist) you will probably need to instantiate an error handler. The following line and error function can be added to your code and it will trap a COM error, set @error to 1 and return control to the next line where you can react accordingly:

; Set a COM Error handler -- only one can be active at a time (see helpfile)
$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

;;;

Func MyErrFunc()
; Set @ERROR to 1 and return control to the program following the trapped error
    SetError(1)
EndFunc  ;==>MyErrFunc

Dale

I gave that code a try, it bombed, I don't get an error everytime with my original code, the problem I think now is that when I still have a session up and try to login with the script I am automatically forwarded to a page that does not contain any forms. So I think that when it tries to run...

For $form in $forms
            $fes = _IEFormElementGetCollection($form)
            For $fe in $fes
                if StringInStr($fe.name, "password") then
                    $passwordField = $fe.name
                endIf
            Next
        Next

It pukes because there are no forms. I have been trying to insert a conditional to ignore that part if there are no forms but I havn't had any success yet.

<{POST_SNAPBACK}>

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 for the help Dale, I appreciate it. I have tried to integrate the error trapping you posted but I am not using it correctly. No matter what I do @error stays at 0. Here is what I have.....

#include <IE.au3>
HotKeySet("!n", "neatadminLogin")
HotKeySet("^+f", "getFormInfo")
HotKeySet("^+t", "terminate")

$address = ""
$user32 = DllOpen("user32")

While 1 
    sleep(10)
WEnd

func neatadminLogin()
    
;prompt for dev, test or uat addressd
    SplashTextOn("Choose the Environment","Press D for Development" & @CRLF & "Press T for System Test" & @CRLF & "Press U for UAT","200","60","-1","-1",0,"Tahoma","10","400")
            
    while 1
        If _IsPressed(44) = 1 Then 
            $address = "http://n-dev-as1:7777/neat"
            ExitLoop
        endIf
        If _IsPressed(54) = 1 Then 
            $address = "http://n-test-as1:7777/neat"
            ExitLoop
        endIf
        If _IsPressed(55) = 1 Then 
            $address = "http://n-test-as1:7779/neat"
            ExitLoop
        endIf
        sleep(1)
    wend
    
    SplashOff()         
        
; Create a browser window and navigate to the web address
    $oIE = _IECreate()
    _IENavigate($oIE, $address)
    
;Maximize the window
    WinSetState("NEAT - Microsoft Internet Explorer", "", @SW_MAXIMIZE)
    
;acquire the deviously hidden dynamic password field name.
    $oDoc = _IEDocumentGetObj($oIE) 
    $forms = _IEFormGetCollection($oDoc)    
; Set a COM Error handler 
    $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
;MsgBox(262144,'Debug line ~49','Selection:' & @lf & '@ERROR' & @lf & @lf & 'Return:' & @lf & @ERROR & @lf & @lf & '@Error:' & @lf & @Error);### Debug MSGBOX
    If @ERROR = 1 Then  
    else
        For $form in $forms
            $fes = _IEFormElementGetCollection($form)
            For $fe in $fes
                if StringInStr($fe.name, "password") then
                    $passwordField = $fe.name
                endIf
            Next
        Next    
        
    ; get pointers to the login form and username and password fields
        $o_form = _IEFormGetObjByName($oIE, "my_account_fm")
        $o_login = _IEFormElementGetObjByName($o_form, "my_account_login")
        $o_password = _IEFormElementGetObjByName($o_form, $passwordField)
        
    ; Set field values and submit the form
        _IEFormElementSetValue($o_login, "neatadmin")
        _IEFormElementSetValue($o_password, "ne@t@dm1n")
        _IEFormSubmit($o_form)
    endIf
endFunc

;

Func _IsPressed($hexKey)
    Local $aR, $bRv
    $hexKey = '0x' & $hexKey
    $aR = DllCall($user32, "int", "GetAsyncKeyState", "int", $hexKey)   
    If $aR[0] <> 0 Then
        $bRv = 1
    Else
        $bRv = 0
    EndIf   
    Return $bRv
EndFunc  

;

func getFormInfo()
    $oIE = _IECreate()
    _IENavigate($oIE, "http://n-dev-as1:7777/neat/")
    $oDoc = _IEDocumentGetObj($oIE)
    
    $forms = _IEFormGetCollection($oDoc)
    For $form in $forms
        ConsoleWrite("Form name: " & $form.name & @CR)
        $fes = _IEFormElementGetCollection($form)
        For $fe in $fes
            ConsoleWrite(@Tab & $fe.name & @TAB & "Type: " & $fe.type & @CR)
        Next
    Next
endFunc

;

Func Terminate()
    DllClose($user32)
    Exit
EndFunc

;

Func MyErrFunc()    
    SetError(1); Set @ERROR to 1 and return control to the program following the trapped error
EndFunc 

;
Link to comment
Share on other sites

Please try putting the ObjEvent near the top of your code (in the main program logic before your functions). If that doesn't work, please try with a very simple reproducer and/or look at the example in the helpfile (under Function Reference -> Obj/COM Reference, near the bottom).

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

Ok a simpler example:

#include <IE.au3>

$oComError = ObjEvent("AutoIt.Error","comError"); Install a custom error handler

$oIE = _IECreate()
_IENavigate($oIE, "http://www.iodynamics.com/education/root101.html")

$oDoc = _IEDocumentGetObj($oIE)    
$forms = _IEFormGetCollection($oDoc)

If @ERROR Then    
    Msgbox(0,"","Error")
else
    Msgbox(0,"","Error Free.")
endIf

;

Func comError() 
   SetError(1) 
Endfunc

From what I can tell this isn't throwing a com error, at least not one that is being trapped by the error object. That web page is a random one from my favorites, I chose it because it has no forms, I searched the source even to be sure.

Edited by Hooch
Link to comment
Share on other sites

Correct, no COM error here. Asking for the form collection where there are no forms simply returns an empty collection, not an error. If you add this line before your If THen Else statement you'll trigger the error handler:

$oTmp = $forms.bogus

You may have to be more diligent on checking return values to try to trap all the troubles.

For the $forms collection you can check to see how many forms were found with $forms.length

Some things may execute without error, but may return 0 for example instead of an object. If you then try to pass that 0 into another function that expects an object you'll get the error then.

Dale

Ok a simpler example:

#include <IE.au3>

$oComError = ObjEvent("AutoIt.Error","comError"); Install a custom error handler

$oIE = _IECreate()
_IENavigate($oIE, "http://www.iodynamics.com/education/root101.html")

$oDoc = _IEDocumentGetObj($oIE)    
$forms = _IEFormGetCollection($oDoc)

If @ERROR Then    
    Msgbox(0,"","Error")
else
    Msgbox(0,"","Error Free.")
endIf

;

Func comError() 
   SetError(1) 
Endfunc

From what I can tell this isn't throwing a com error, at least not one that is being trapped by the error object. That web page is a random one from my favorites, I chose it because it has no forms, I searched the source even to be sure.

<{POST_SNAPBACK}>

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

Yea since I last posted I went through your various functions in IE.au3 and found _IEFormGetCount(), this allowed me to check for the presence of a form first thusly avoiding my issue.

Sorry, I was a little intimidated by the new COM stuff so I was looking for a little hand holding. Anyways very nice work, this is going to allow me to script a lot of use case testing that we need to do on a huge application currently in development. You Rock :whistle:

Link to comment
Share on other sites

  • 3 weeks later...

Hello all,

Thanks to those of you who have developed these extensions to autoit.

I have run into a snag and am hoping that there is a simple solution. I have a web page dialog that is launched by an application, and I need to be able to selectively click some checkboxes on the web page dialog based on the adjacent text. Autoit window snoop report is below. The class of the window is

"Internet Explorer_TridentDlgFrame" which does not seem to show up as a ShellWindow under the $o_Shell.Windows collection in _IEAttach.... Thus I can't get at the controls on the page.

Thus although the form control that I need to work with is Internet Explorer_Server1, the window it is in is not recognized as being a ShellWindow (as best I can tell). Is there another collection under the Shell.Application object that I can go after? Apologies if there is a simple solution, I have a limited COM background. Image of the window that I am trying to control is attached. All of the basic tricks like right-clicking to get at source HTML, etc are disabled.

Thanks!

Walt L.

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<

Title: Associate exams -- Web Page Dialog

Class: Internet Explorer_TridentDlgFrame

Size: X: 310 Y: 318 W: 800 H: 368

>>>>>>>>>>> Mouse Details <<<<<<<<<<<

Screen: X: 796 Y: 392

Cursor ID: 2

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<

RGB: Hex: 0xC0C0C0 Dec: 12632256

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Size: X: 0 Y: 0 W: 792 H: 330

Control ID:

ClassNameNN: Internet Explorer_Server1

Text:

Style: 0x56000000

ExStyle: 0x00000000

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<

Edited by wliebkem
Link to comment
Share on other sites

Unfortunately, this is a puzzle to me as well. I don't have an answer to this at this point, but I'll throw out some bread crumbs in hopes that others have the time to look at this as well and find more clues.

This appears to be a window opened with a window.showmodaldialog call. I found an example of this here: http://popuptest.com/popuptest9.html

One thought was that this might show as a child window -- like you'd get with window.open() -- that we'd be able to drill to from the parent. This appears to NOT be the case (so I've read, but haven't tested).

It appears to be an independant window and it doesn't show up in the Shell Window collection. Hopefully there is an easy answer here, but I don't see it yet.

You can certainly treat it like a Win32 window and manipulate it with standard AutoIt commands, but I see no way yet to obtain an object reference to it that would allow you to manipulate it with COM.

Ideas from others welcome here.

Dale

I have run into a snag and am hoping that there is a simple solution.  I have a web page dialog that is launched by an application, and I need to be able to selectively click some checkboxes on the web page dialog based on the adjacent text.  Autoit window snoop report is below.  The class of the window is

"Internet Explorer_TridentDlgFrame" which does not seem to show up as a ShellWindow under the $o_Shell.Windows collection in _IEAttach.... Thus I can't get at the controls on the page.

<{POST_SNAPBACK}>

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. I am going to try to search for some sort of hidden parent window, and also go through the OLE/COM Object Viewer to see if I can find some clue as to how to get at it. I'll post how it turns out.

Walt L.

One thought was that this might show as a child window -- like you'd get with window.open() -- that we'd be able to drill to from the parent.  This appears to NOT be the case (so I've read, but haven't tested).

It appears to be an independant window and it doesn't show up in the Shell Window collection.  Hopefully there is an easy answer here, but I don't see it yet.

You can certainly treat it like a Win32 window and manipulate it with standard AutoIt commands, but I see no way yet to obtain an object reference to it that would allow you to manipulate it with COM.

Ideas from others welcome here.

Dale

<{POST_SNAPBACK}>

Link to comment
Share on other sites

Can anyone teach me how to get the current weather from the following site?

http://pda.hko.gov.hk/wxreporte.htm

<HTML>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>

Current Weather

</title>

</head>

<body bgcolor="#d7f0ff" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<table width="220" border="0" cellspacing="0" cellpadding="5"><tr><td valign="top">

<p align="center"><img src="/img/logo_dblue.jpg" alt="Hong Kong Observatory Logo" width="220"></p>

<p>Bulletin updated at 09:02 HKT <br>10/

Sep

/2005</p>

<p></p>

<p align="center"><b><u>Current Weather</u></b></p>

AT

9 A.M.

AT THE HONG KONG OBSERVATORY :<br>

AIR TEMPERATURE : 28 DEGREES CELSIUS<br>

RELATIVE HUMIDITY : 78 PER CENT

<p></p>DURING THE PAST HOUR

THE MEAN UV INDEX RECORDED AT KING'S PARK : 2<br>

INTENSITY OF UV RADIATION : LOW<br><font color="red"></font><p>THE AIR TEMPERATURES AT OTHER PLACES WERE:</p>

<table width="220" border="0" cellspacing="0" cellpadding="5">

<tr>

<td>KING'S PARK</td>

<td>28 DEGREES

;<br>

</td>

</tr>

<tr>

<td>WONG CHUK HANG</td>

<td>28 DEGREES

;<br>

</td>

</tr>

<tr>

<td>TA KWU LING</td>

<td>27 DEGREES

;<br>

</td>

</tr>

<tr>

<td>LAU FAU SHAN</td>

<td>26 DEGREES

;<br>

</td>

</tr>

<tr>

<td>TAI PO</td>

<td>27 DEGREES

;<br>

</td>

</tr>

<tr>

<td>SHA TIN</td>

<td>28 DEGREES

;<br>

</td>

</tr>

<tr>

<td>TUEN MUN</td>

<td>28 DEGREES

;<br>

</td>

</tr>

<tr>

<td>TSEUNG KWAN O</td>

<td>28 DEGREES

;<br>

</td>

</tr>

<tr>

<td>SAI KUNG</td>

<td>28 DEGREES

;<br>

</td>

</tr>

<tr>

<td>CHEUNG CHAU</td>

<td>27 DEGREES

;<br>

</td>

</tr>

<tr>

<td>CHEK LAP KOK</td>

<td>28 DEGREES

;<br>

</td>

</tr>

<tr>

<td>TSING YI</td>

<td>28 DEGREES

;<br>

</td>

</tr>

<tr>

<td>SHEK KONG</td>

<td>28 DEGREES

.<br>

</td>

</tr>

</table>

<p></p>BETWEEN MIDNIGHT AND 9 A.M. THE MINIMUM TEMPERATURE WAS 26.8 DEGREES CELSIUS AT THE HONG KONG OBSERVATORY.<br>

</td></tr></table>

<a href="maine.htm"><img src="img/home.gif" alt="home" border="0"></a><a href="maine.htm#report"><img src="img/back.gif" alt="back" border="0"></a>

</body>

</HTML>

Link to comment
Share on other sites

Can anyone teach me how to get the current weather from the following site?

http://pda.hko.gov.hk/wxreporte.htm

<{POST_SNAPBACK}>

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

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

Thanks a lot!

I think I need to have more example on how to use those function, actually where can I find examples for those functions? And Is there a list of all the object that I can use?

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

<{POST_SNAPBACK}>

Link to comment
Share on other sites

Reply 3 in the post that contains the IE.au3 UDF contains a number of examples. Other than that, you'll need to look at the comment section at the top of IE.au3 and the comment section of each function in IE.au3 for more detail.

Dale

Thanks a lot!

I think I need to have more example on how to use those function, actually where can I find examples for those functions? And Is there a list of all the object that I can use?

<{POST_SNAPBACK}>

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've been interested in writing some scripts to automate work here at the office, and it will require reading HTMLfrom IE. I've been putting it off now because I haven't had the time to dedicate overcoming many obstacles with reading the source, etc. But your functions handle that for me already, and it is greatly appreciated. I haven't tried them yet, but at first glance there is some seriously good work here.

My first run with this code will be to finish my automated install script for Comcast High Speed Internet. I need to install this software, at least, 10 times a day and wanted to automate it, but the problem was knowing how fast or slow the computer in use was responding before moving to the next action for the next window. And since the installer basically launches an IE window and navigates through some HTML pages I think your script will work.

Have you tried anything like this? In any event, I'll et you know how it goes, and if new functions can be created to accomodate such a task I'll post what I come up with.

**EDIT: It doesn't work with the installer application. One version of the installer appears to use VB forms, and another disk version that has HTML pages on it appears to use the HTML pages as an include. The script will now allow me to execute an _IEAttach() to the screen.

Edited by AutoITPimp
Link to comment
Share on other sites

The _IESubmit() function does not seem to work for me. Here is my code, and nothing is happening to submit the form.

#include <IE.au3>

$oIE = _IECreate()
_IENavigate($oIE, "http://www.mydomain.com/dir/dir/login.jsp")
_IELoadWait($oIE, 2000)

; get pointers to the login form and username and password fields
$o_form = _IEFormGetObjByName($oIE, "form1")
$o_username = _IEFormElementGetObjByName($o_form, "username")
$o_password = _IEFormElementGetObjByName($o_form, "password")

; Set field values and submit the form
_IEFormElementSetValue($o_username, "myusername")
_IEFormElementSetValue($o_password, "mypassword")
_IEFormSubmit($o_form)
Link to comment
Share on other sites

Without seeing the source for the pagte there is no way to really know, but it is very common these days for web applications to NOT USE standard for submit actions, but rather to tie actions to script on the submit button(s) instead.

You'll probably need to perform a .click event on the button instead of using the standard _IESubmit call. There are some exaples of this scattered through the forum, but one approach is to get the Item index of the button you want and to .click it:

$o_all = _IETagNameAllGetCollection ($oIE)
$o_button = $o_all.item(index)
$o_button.click

or just

$o_all = _IETagNameAllGetCollection ($oIE)
$o_all.item(index).click

Reply 37 in this thread has a script for displaying information about your web page and will help you get the item index.

Regarding our other query about the IE window that you cannot attach to with _IEAttach... a couple of other people lately have found web apps that are using a ShowModalDialog call. This creates a unique window that does not appear in the Shell collection. There is no anser to this puzzle yet.

Dale

The _IESubmit() function does not seem to work for me.  Here is my code, and nothing is happening to submit the form.

#include <IE.au3>

$oIE = _IECreate()
_IENavigate($oIE, "http://www.mydomain.com/dir/dir/login.jsp")
_IELoadWait($oIE, 2000)

; get pointers to the login form and username and password fields
$o_form = _IEFormGetObjByName($oIE, "form1")
$o_username = _IEFormElementGetObjByName($o_form, "username")
$o_password = _IEFormElementGetObjByName($o_form, "password")

; Set field values and submit the form
_IEFormElementSetValue($o_username, "myusername")
_IEFormElementSetValue($o_password, "mypassword")
_IEFormSubmit($o_form)

<{POST_SNAPBACK}>

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 trying to select a check box on a web page. I know the value which will be next to the checkbox, but depending on how many packages are the a delivery, the checkbox could be in a different location on the page (different number of TABs to get to it). Would someone help me out. I would really appreciate it.

Thanks.

Did you read the posts preceeding yours?

Lots of examples "How to..." Read them and If you're stuck somewhere with your Code. Post it and then somone might help you solve the problem...

Say: "Chuchichäschtli"My UDFs:_PrintImage UDF_WinAnimate UDFGruess Raindancer
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...