Jump to content

Help with IE form fill


horstj
 Share

Recommended Posts

Hi All,

I am having a bit of trouble filling in some input boxes on a certain website. I have tried all kinds of different iterations of the following script, but can't get anything to work.

#include <IE.au3>
Run("C:\Program Files (x86)\Internet Explorer\iexplore.exe -new http://acc.rollernet.us/","")
$RollerHwnd = WinWaitActive("[TITLE:Roller Network Control Center - Windows Internet Explorer; CLASS:IEFrame]")
$rollerIE = _IEAttach($RollerHwnd,"HWND")
$rollerForm = _IEFormGetCollection($rollerIE)
;Logs into the Rollernet admin portal
$roller_username = _IEFormElementGetObjByName($rollerForm,"username")
$roller_password = _IEFormElementGetObjByName($rollerForm,"password")
_IEFormElementSetValue($roller_username,"Username")
_IEFormElementSetValue($roller_password,"Password")

I have used a variation of this exact code for another website without any problems. Does anyone see what I am missing? Any help would be greatly appreciated!

Link to comment
Share on other sites

You need to add some error checking to your code! Every _IE* function sets @error if there was a problem.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks water. I didn't do any error checking with @error, but here is the output when I run the script:

IE.au3 V2.4-0 Error from function _IEPropertyGet, $_IEStatus_InvalidObjectType

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

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

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

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

From all of my testing, it seems that the problem exists around the _IEFormGetCollection function. Is that the best way to get the password and username input fields? They are in an unamed form which makes things interesting as well.

Link to comment
Share on other sites

Thanks DedekPredek. Did you test that out on your machine at all? I had tried that before and it actually gives me the same errors as my previous post, but with

--> IE.au3 V2.4-0 Warning from function _IEFormGetCollection, $_IEStatus_NoMatch

added. Any other suggestions?

Link to comment
Share on other sites

Dedek, Sorry for my ignorance here, but would my code now look like this

#include <IE.au3>
Run("C:\Program Files (x86)\Internet Explorer\iexplore.exe -new https://acc.rollernet.us/","")
$RollerHwnd = WinWait("Roller Network Control Center - Windows Internet Explorer","")
$rollerIE = _IEAttach($RollerHwnd,"HWND")
_IELoadWait($rollerIE)
$rollerForm = _IEFormGetCollection($rollerIE)
;Logs into the Rollernet admin portal
$roller_username = _IEFormElementGetObjByName($rollerForm,"username")
$roller_password = _IEFormElementGetObjByName($rollerForm,"password")
_IEFormElementSetValue($roller_username,"Username")
_IEFormElementSetValue($roller_password,"Password")

I still cannot get it to fill in the username and password fields.

Edited by horstj
Link to comment
Share on other sites

As I said in post #2 you need to add some error checking. Which of the functions you call sets @error?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

#include <IE.au3>
$oIE=_IECreate("https://acc.rollernet.us")
$oObj = _IEGetObjByName($oIE,"username")
_IEPropertySet($oObj,"innertext","MyUserId")
$oObj = _IEGetObjByName($oIE,"password")
_IEPropertySet($oObj,"innertext","MyPassword")
$oObj = _IEGetObjByName($oIE,"submit")
_IEAction($oObj,"click")
Exit

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

As you can see from the help file:

_IEAttach: 7 ($_IEStatus_NoMatch) = No Match ==> The IE instance you try to attach to couldn't be found

_IELoadWait: 3 ($_IEStatus_InvalidDataType) = Invalid Data Type ==> Error caused by unsuccessfull _IEAttach

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 5 years later...
On 2/13/2013 at 7:59 PM, Exit said:

 

#include <IE.au3>
$oIE=_IECreate("https://acc.rollernet.us")
$oObj = _IEGetObjByName($oIE,"username")
_IEPropertySet($oObj,"innertext","MyUserId")
$oObj = _IEGetObjByName($oIE,"password")
_IEPropertySet($oObj,"innertext","MyPassword")
$oObj = _IEGetObjByName($oIE,"submit")
_IEAction($oObj,"click")
Exit

 

How to to fill this forum when webpage already opened ?

Link to comment
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
 Share

×
×
  • Create New...