Submit a specified Form
#include <IE.au3>
_IEFormSubmit ( ByRef $oObject [, $iWait = 1] )
$oObject | Object variable of an InternetExplorer.Application, Form object |
$iWait | [optional] specifies whether to wait for page to load before returning 0 = Return immediately, not waiting for page to load 1 = (Default) Wait for page load to complete before returning |
Success: | None. |
Failure: | 0 or -1 and sets the @error flag to non-zero. |
@error: | 1 ($_IEStatus_GeneralError) - General Error 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 6 ($_IEStatus_LoadWaitTimeout) - Load Wait Timeout 8 ($_IEStatus_AccessIsDenied) - Access Is Denied 9 ($_IEStatus_ClientDisconnected) - Client Disconnected |
@extended: | Contains invalid parameter number |
For many HTML forms it is not sufficient to use _IEFormSubmit() because there is often custom JavaScript tied to an onClick event for its Submit button.
In these cases you'll need to simulate a click of the submit button instead of using _IEFormSubmit(). See the example for the "click" action of _IEAction().
As well, some form processing relies on the "value" of the submit button being passed along with the rest of the form data (often when there is more than one submit button in the form and they are designed to trigger different results).
This function will not result in a submit button value being passed. The solution is to use the "click" action of _IEAction() as above.
If you experience trouble with the automatic _IELoadWait() called by default, please set $iWait parameter to 0 and call _IELoadWait() from your script, passing it the InternetExplorer object.
_IEFormElementGetCollection, _IEFormElementGetObjByName, _IEFormGetCollection, _IEFormGetObjByName, _IEFormReset, _IELoadWait
; Open a browser with the form example, fill in a form field and submit the form
#include <IE.au3>
Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
Local $oText = _IEFormElementGetObjByName($oForm, "textExample")
_IEFormElementSetValue($oText, "Hey! It works!")
Sleep(2000)
_IEFormSubmit($oForm)
; Get a reference to a specific form element and set its value.
; In this case, submit a query to the Google search engine
#include <IE.au3>
Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetCollection($oIE, 0)
Local $oQuery = _IEFormElementGetCollection($oForm, 4)
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
Sleep(2000)
_IEFormSubmit($oForm)
; Get a reference to a specific form element and set its value.
; Call _IELoadWait manually if the default _IELoadWait experiences trouble.
#include <IE.au3>
Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetCollection($oIE, 0)
Local $oQuery = _IEFormElementGetCollection($oForm, 4)
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm, 0)
_IELoadWait($oIE)