Jump to content
Sign in to follow this  
imacleod

Is this a form?

Recommended Posts

imacleod

As will become obvious I don't know much about what I'm looking at here; I've been trying to get a script to work with a page that has the following body:

<BODY BACKGROUND="bluepa1.gif">

<table border=0>

<tr><td align=center valign=top><a href="http://host.example.com/app">

<img src="tractor.gif" border=0><h5> Return to main menu</h5></a></td>

<td><center><h1>SIDA - Delete or Update IDs</h1></center></td></tr>

</table>

<form method="GET" action="/cdssida.wrkexec" onsubmit = "return TestUser()">

<table><tr>

<td><strong>Update/change date info for </strong>

<input type=TEXT name="ACQUSER" value = "" size=8 maxlength=8 >

</td>

<td>

<input type=SUBMIT value = "Update" name= "ACQUIRE" >

</td>

</tr>

</table>

<input type=hidden name=PAGENAME value=SIDAMAIN>

<input type=hidden name="ACQUIRE" value = 'Update'>

</form>

<P>

</BODY>

I have a csv file from which I want to paste values into the ACQUSER field and submit it within a loop.

I can launch IE , read the file into an array and display the content on screen but I can't see what I should use for the form name when I try work with the ACQUSER field using _IEFormGetObjByName _IEFormElementGetObjByName!

I tried using _IEGetObjByName I get datatype errors for that too. I'm really not sure what the correct approach/library function to use in the above, any pointers appreciated...

Share this post


Link to post
Share on other sites
imacleod

OK, no suggestions or comments so let me rephrase this. I can see the "<form method="GET" action="/cdssida.wrkexec" onsubmit = "return TestUser()"> and the </form> closing it off but the form is not named anywhere, which seems to be integral to the _IEForm functions.

What would be the best approach to access the text input field, insert some code to the body of the page in attempt to label/name the form (not sure if that's feasible or whether it might impact the page's functionailty), or use something other than the _IEForm* functions?

Share this post


Link to post
Share on other sites
Melba23

imacleod,

no suggestions or comments

For future reference we consider 24hrs a reasonable time to wait before bumping your own thread. ;)

Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
water

Use

Local $oForm = _IEFormGetCollection($oIE, 0)
to access the object of the first form on the page and then pass this object to all other _IEForm* functions.

The help file has a lot of examples describing what to do.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
imacleod

Thanks Water,

I've tried using _IEFormGetCollection and copied one of the examples into my script but for some reason I still get DataType errors:

0022: 0-0: Local $oIE = ShellExecute ("iexplore", "http://host/app")

0023: 0-0: WinWaitActive("******* - Windows Internet Explorer")

0025: 0-0: Local $oForms = _IEFormGetCollection ($oIE)

--> IE.au3 V2.4-0 Error from function _IEFormGetCollection, $_IEStatus_InvalidDataType

0026: 3-1: MsgBox(0, "Forms Info", "There are " &amp; @extended &amp; " forms on this page")

0027: 0-0: For $oForm In $oForms

C:UsersIMACLEODDocumentsSIDACSV_import_DebugIt.au3 (85) : ==> Variable must be of type "Object".:

For $oForm In $oForms

For $oForm In $oForms^ ERROR

->11:42:16 AutoIT3.exe ended.rc:1

>Exit code: 1 Time: 20.600

BTW, the ShellExecute and WinWaitActive work fine, the 'Forms Info' message box does pop and reports one form on the page, it doesn't get as far as the nested MsgBox.

I seem to have some fundamental issue... or more likely a basic error in what I'm doing.

Edited by imacleod

Share this post


Link to post
Share on other sites
water

You have to start IE by using the UDF as well (remove ShellExecute and WinWaitActive). Use _IECreate and check the examples in the help file!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
imacleod

Thanks again.

Running _IECreate to launch the app page I get an error

0023: 0-0: Local $oIE = _IECreate("http://host/app")

C:Program Files (x86)AutoIt3IncludeIE.au3 (560) : ==> The requested action with this object has failed.:

WEnd

WEnd^ ERROR

->13:45:01 AutoIT3.exe ended.rc:1

>Exit code: 1 Time: 17.401

On re-running the script I've also got these different errors:

C:Program Files (x86)AutoIt3IncludeIE.au3 (549) : ==> The requested action with this object has failed.:

While Not (String($o_object.readyState) = "complete" Or $o_object.readyState = 4 Or $f_Abort)

While Not (String($o_object.readyState^ ERROR

->14:21:58 AutoIT3.exe ended.rc:1

>Exit code: 1 Time: 2.113

and:

C:Program Files (x86)AutoIt3IncludeIE.au3 (625) : ==> The requested action with this object has failed.:

$oTemp = $o_object.document.parentWindow

$oTemp = $o_object.document^ ERROR

->14:24:17 AutoIT3.exe ended.rc:1

>Exit code: 1 Time: 2.230

I read some other threads and enabled/included _IEErrorHandlerRegister() and I get (with more of the debug output):

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:UsersIMACLEODDocumentsSIDACSV_import.au3" /UserParams

+>13:50:38 Starting AutoIt3Wrapper v.2.1.0.33 Environment(Language:0409 Keyboard:00000809 OS:WIN_7/ CPU:X64 OS:X64)

>Running AU3Check (1.54.22.0) from:C:Program Files (x86)AutoIt3

+>13:50:38 AU3Check ended.rc:0

>Running:(3.3.8.1):C:Program Files (x86)AutoIt3autoit3.exe "C:UsersIMACLEODDocumentsSIDACSV_import.au3"

--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop

!> Starting in DebugMode..

Line: @error-@extended: Line syntax

0001: 0-0: #include <GUIConstants.au3>

0002: 0-0: #include <Array.au3>

0003: 0-0: #include <File.au3>

0004: 0-0: #include <String.au3>

0005: 0-0: #include <IE.au3>

0007: 0-0: #AutoIt3Wrapper_run_debug_mode=Y

0008: 0-0: _IEErrorHandlerRegister()

0012: 0-0: Global Const $CSVFILE = "renewals.csv"

0013: 0-0: Global Const $DELIM = "," ;the delimiter in the CSV file

0014: 0-0: Global $i, $arrContent, $arrLine, $res = 0

0023: 0-0: Local $oIE = _IECreate("http://host/app")

The app page pops, then after 5minutes I get:

--> IE.au3 V2.4-0 Warning from function _IELoadWait, $_IEStatus_LoadWaitTimeout

0026: 6-0: Local $oForms = _IEFormGetCollection ($oIE)

--> COM Error Encountered in CSV_import_DebugIt.au3

----> $IEComErrorScriptline = 2227

----> $IEComErrorNumberHex = 80010108

----> $IEComErrorNumber = -2147417848

----> $IEComErrorWinDescription = The object invoked has disconnected from its clients.

----> $IEComErrorDescription =

----> $IEComErrorSource =

----> $IEComErrorHelpFile =

----> $IEComErrorHelpContext = 0

----> $IEComErrorLastDllError = 0

--> COM Error Encountered in CSV_import_DebugIt.au3

----> $IEComErrorScriptline = 1088

----> $IEComErrorNumberHex = 000000A9

----> $IEComErrorNumber = 169

----> $IEComErrorWinDescription = Variable must be of type 'Object'.

----> $IEComErrorDescription =

----> $IEComErrorSource =

----> $IEComErrorHelpFile =

----> $IEComErrorHelpContext = 0

----> $IEComErrorLastDllError = 0

0027: 0-0: MsgBox(0, "Forms Info", "There are " & @extended & " forms on this page")

0028: 0-0: For $oForm In $oForms

--> COM Error Encountered in CSV_import_DebugIt.au3

----> $IEComErrorScriptline = 71

----> $IEComErrorNumberHex = 000000A9

----> $IEComErrorNumber = 169

----> $IEComErrorWinDescription = Variable is not of type 'Object'.

----> $IEComErrorDescription =

----> $IEComErrorSource =

----> $IEComErrorHelpFile =

----> $IEComErrorHelpContext = 0

----> $IEComErrorLastDllError = 0

0032: 169-0: Local $oText = _IEFormElementGetObjByName($oForm, "ACQUSER")

--> IE.au3 V2.4-0 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType

0034: 3-1: $res = _FileReadToArray($CSVFILE, $arrContent)

0035: 0-0: If $res = 1 Then

0036: 0-0: For $i = 1 To $arrContent[0]

0037: 0-0: $arrLine = StringSplit($arrContent[$i], $DELIM)

0038: 1-0: If IsArray($arrLine) And $arrLine[0]<>0 Then

0040: 0-0: _IEAction($oText, "focus")

--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType

0041: 3-1: Send("ThisWorks")

0043: 0-0: _ArrayDisplay($arrLine)

0044: 0-0: Else

0047: 0-0: Next

0048: 0-0: Else

+>14:04:24 AutoIT3.exe ended.rc:0

>Exit code: 0 Time: 415.205

In this configuration _IEFormGetCollection concludes there are no forms on the page.

This first attempt at a script is proving more challenging than I bargained for!

Edited by imacleod

Share this post


Link to post
Share on other sites
water

What's the application you try to automate?

BTW: In post #5 the link points to the real address.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
imacleod

It's a simple web interface to a mainframe system; apart from some text and hyperlinks it has one text input field and a submit button:

<HTML>

<HEAD>

<TITLE> SIDA</TITLE>

<script language="Javascript">

function TestUser() {

if (document.forms[0].ACQUSER.value!=''){

document.forms[0].ACQUIRE.value ='Update'

return true;

}

alert("An ID must be supplied for this action");

return false;

}

</script>

</HEAD>

<BODY BACKGROUND="bluepa1.gif">

<table border=0>

<tr><td align=center valign=top><a href="http://host/app">

<img src="tractor.gif" border=0><h5> Return to main menu</h5></a></td>

<td><center><h1>Update IDs sponsored by IMACLEOD</h1></center></td></tr>

</table>

<form method="GET" action="/sida.wrkexec" onsubmit = "return TestUser()">

<table>

<td><strong>Update expiration date info for </strong>

<input type=TEXT name="ACQUSER" value = "" size=8 maxlength=8 >

</td>

<td>

<input type=SUBMIT value = "Update" name= "ACQUIRE" >

</td>

</tr>

</table>

<input type=hidden name=PAGENAME value=SIDAMAIN>

<input type=hidden name="ACQUIRE" value = 'Update'>

</form>

<P>

</BODY>

</HTML>

The page launches OK, and works OK if driven manually; it's just the processing of the variables in AutoIt where I'm experiencing issues.

Edited by imacleod

Share this post


Link to post
Share on other sites
DaleHohm

You can use shellexecute if you choose, but then you would use _IEAttach to get the $oIE object.

If you want to troubleshoot the _IECreate issue, you can try adding the noWait flag - but then you have to take care that the page is loaded before your other function calls. The source of this error in IE.au3 is corrected in the alpha release of AutoIt.

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

Share this post


Link to post
Share on other sites
imacleod

Thanks all, I'd be well and truly lost without your support.

It would be really useful if page load was managed automatically so I'll have another stab at shellexecute route.

Unfortunately I've had to go through an internal review process to get 3.3.8.1 approved for so if I can avoid having to change that it will save some time.

Share this post


Link to post
Share on other sites
BrewManNH

You wouldn't need to update the executables of AutoIt, as long as the changes in the UDF don't access any new functionality in the new exe.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
DaleHohm

The changes in IE.au3 require the changes to AutoIt included in the beta - 3.3.9.4.

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

Share this post


Link to post
Share on other sites
BrewManNH

Guess that answered that question. :)


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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  

×