Sign in to follow this  
Followers 0
MarkG

Scripting data entry into input fields

11 posts in this topic

I have created a script that signs in the user by entering the signin id and password into the two input fields on the screen. The way I entered the information is by sending TAB characters to position the cursor at the first input field, using the send command to enter the info and then send another tab to get to the next input field to enter the password. Everything worked fine on my version/copy of IE. When I gave it to user their version/copy of IE required a different number of TABs to get to the input field.

Is there a general fool proof method of positioning the cursor at the first input field?

Share this post


Link to post
Share on other sites



Use "AutoIt Window Info" (It's usually included in the directory "C:\Program Files\AutoIt3\Au3Info.exe" or under Start -> All Programs -> AutoIt v3 -> AutoIt Window Info) to retrieve some reference or notes about the text or control id or instance and use Control* function.. If applicable.

Share this post


Link to post
Share on other sites

Use "AutoIt Window Info" (It's usually included in the directory "C:\Program Files\AutoIt3\Au3Info.exe" or under Start -> All Programs -> AutoIt v3 -> AutoIt Window Info) to retrieve some reference or notes about the text or control id or instance and use Control* function.. If applicable.

I have tried that and I don't see any info that will allow me to get to that field. Included below is the summary info from AutoIt Window info:

>>>> Window <<<<

Title: Office Channel Login - Microsoft Internet Explorer

Class: IEFrame

Position: -4, -4

Size: 1032, 746

Style: 0x17CF0000

ExStyle: 0x00000100

Handle: 0x001E0656

>>>> Control <<<<

Class: Internet Explorer_Server

Instance: 1

ClassnameNN: Internet Explorer_Server1

Advanced (Class): [CLASS:Internet Explorer_Server; INSTANCE:1]

ID:

Text:

Position: 0, 86

Size: 1024, 603

ControlClick Coords: 361, 254

Style: 0x56000000

ExStyle: 0x00000000

Handle: 0x002E0624

>>>> Mouse <<<<

Position: 361, 366

Cursor ID: 2

Color: 0xF8FDF6

>>>> StatusBar <<<<

1: Done

2:

3:

4:

5:

6:

7: SSL Secured (128 Bit)

8: Internet

>>>> Visible Text <<<<

Links

https://websrv01.physician-to-go.net/proxy..../home/login.htm

https://websrv01.physician-to-go.net/proxy..../home/login.htm

Done

>>>> Hidden Text <<<<

Share this post


Link to post
Share on other sites

I have created a script that signs in the user by entering the signin id and password into the two input fields on the screen. The way I entered the information is by sending TAB characters to position the cursor at the first input field, using the send command to enter the info and then send another tab to get to the next input field to enter the password. Everything worked fine on my version/copy of IE. When I gave it to user their version/copy of IE required a different number of TABs to get to the input field.

Is there a general fool proof method of positioning the cursor at the first input field?

Use the _IE* functions of the IE.au3 UDF. This should be pretty straight forward. Look at Example 3 under _IEFormElementSetValue() in the help file.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Use the _IE* functions of the IE.au3 UDF. This should be pretty straight forward. Look at Example 3 under _IEFormElementSetValue() in the help file.

:)

I reviewed the example as suggested and I am getting an error "The requested action resulted in an error".

Here is the first few lines of my code that is causing the problem. Any idea what I am doing wrong?

_____________________________

#include <IE.au3>

$oIE = _IECreate ("https://websrv01.physician-to-go.net/proxy.cgi/off/home/login.htm", 1, 1, 0)

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

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

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

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

$o_signin = _IEFormElementGetObjByName ($o_form, "submit")

_____________________________

Share this post


Link to post
Share on other sites

I reviewed the example as suggested and I am getting an error "The requested action resulted in an error".

Here is the first few lines of my code that is causing the problem. Any idea what I am doing wrong?

#include <IE.au3> 
$oIE = _IECreate ("https://websrv01.physician-to-go.net/proxy.cgi/off/home/login.htm", 1, 1, 0)

; get pointers to the login form and username, password and signin fields
$o_form = _IEFormGetObjByName ($oIE, "form1")
$o_login = _IEFormElementGetObjByName ($o_form, "login")
$o_password = _IEFormElementGetObjByName ($o_form, "password")
$o_signin = _IEFormElementGetObjByName ($o_form, "submit")
But where does it fail, and what is the exact error?

Make sure you have _IEErrorHandlerRegister() near the top of your script, and run it under SciTE. Then post the error you get from the console pane of SciTE. The useful details will be in there. The code you posted is fine, provided the object names are correct, and form1 is not inside an iFrame, or something like that. The exact error details will tell.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

But where does it fail, and what is the exact error?

Make sure you have _IEErrorHandlerRegister() near the top of your script, and run it under SciTE. Then post the error you get from the console pane of SciTE. The useful details will be in there. The code you posted is fine, provided the object names are correct, and form1 is not inside an iFrame, or something like that. The exact error details will tell.

:)

Here is the results from running it under SciTE

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

--> COM Error Encountered in Fl SHOTS.au3

----> $IEComErrorScriptline = 1247

----> $IEComErrorNumberHex = 80020009

----> $IEComErrorNumber = -2147352567

----> $IEComErrorWinDescription = Unspecified error

----> $IEComErrorDescription =

----> $IEComErrorSource =

----> $IEComErrorHelpFile =

----> $IEComErrorHelpContext = 0

----> $IEComErrorLastDllError = 0

--> COM Error Encountered in Fl SHOTS.au3

----> $IEComErrorScriptline = 1262

----> $IEComErrorNumberHex = 80020009

----> $IEComErrorNumber = -2147352567

----> $IEComErrorWinDescription = Unspecified error

----> $IEComErrorDescription =

----> $IEComErrorSource =

----> $IEComErrorHelpFile =

----> $IEComErrorHelpContext = 0

----> $IEComErrorLastDllError = 0

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

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

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

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

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

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

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

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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Here is the results from running it under SciTE

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

This one is normal status when you have $f_attach = 1 in _IECreate() and the page is not already opened.

--> COM Error Encountered in Fl SHOTS.au3

----> $IEComErrorScriptline = 1247

----> $IEComErrorNumberHex = 80020009

----> $IEComErrorNumber = -2147352567

----> $IEComErrorWinDescription = Unspecified error

----> $IEComErrorDescription =

----> $IEComErrorSource =

----> $IEComErrorHelpFile =

----> $IEComErrorHelpContext = 0

----> $IEComErrorLastDllError = 0

--> COM Error Encountered in Fl SHOTS.au3

----> $IEComErrorScriptline = 1262

----> $IEComErrorNumberHex = 80020009

----> $IEComErrorNumber = -2147352567

----> $IEComErrorWinDescription = Unspecified error

----> $IEComErrorDescription =

----> $IEComErrorSource =

----> $IEComErrorHelpFile =

----> $IEComErrorHelpContext = 0

----> $IEComErrorLastDllError = 0

These are not normal. What does the section of code from line 1247 to 1262 in "Fl SHOTS.au3" look like?

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

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

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

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

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

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

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

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

Since the form reference didn't work, all the element references after that were doomed.

So you are looking for the cause of the two COM errors, and why _IEFormGetObjByName() failed to get the form reference.

You had $f_wait = 0 in your _IECreate() posted earlier. Did you do something else to wait for the page to load before attempting to use it?

:)

Edit: Actually this recreates almost exactly what you get, just by trying to get the form before the page is loaded:

#include <IE.au3>

_IEErrorHandlerRegister()

$oIE = _IECreate("http://www.google.com", 1, 1, 0)

$oForm = _IEFormGetObjByName($oIE, "f")

Why did you set $f_wait = 0?

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

This one is normal status when you have $f_attach = 1 in _IECreate() and the page is not already opened.

These are not normal. What does the section of code from line 1247 to 1262 in "Fl SHOTS.au3" look like?

Since the form reference didn't work, all the element references after that were doomed.

So you are looking for the cause of the two COM errors, and why _IEFormGetObjByName() failed to get the form reference.

You had $f_wait = 0 in your _IECreate() posted earlier. Did you do something else to wait for the page to load before attempting to use it?

:)

Edit: Actually this recreates almost exactly what you get, just by trying to get the form before the page is loaded:

#include <IE.au3>

_IEErrorHandlerRegister()

$oIE = _IECreate("http://www.google.com", 1, 1, 0)

$oForm = _IEFormGetObjByName($oIE, "f")

Why did you set $f_wait = 0?

:)

Your last comment "You had $f_wait = 0 in your _IECreate() posted earlier. Did you do something else to wait for the page to load before attempting to use it?" made me think and I found the problem. I was not waiting for the page to load. I put in a WinWaitActive and the problems was fixed.

Are you suggesting that I change the statement from

$oIE = _IECreate ("https://websrv01.physician-to-go.net/proxy.cgi/off/home/login.htm", 1, 1, 0)

TO

$oIE = _IECreate ("https://websrv01.physician-to-go.net/proxy.cgi/off/home/login.htm", 1, 1, 1)

which will do the same as a WinWaitActive?

Where can I see the documentation for all the parameters for the _IECreate function?

Share this post


Link to post
Share on other sites

Your last comment "You had $f_wait = 0 in your _IECreate() posted earlier. Did you do something else to wait for the page to load before attempting to use it?" made me think and I found the problem. I was not waiting for the page to load. I put in a WinWaitActive and the problems was fixed.

Are you suggesting that I change the statement from

$oIE = _IECreate ("https://websrv01.physician-to-go.net/proxy.cgi/off/home/login.htm", 1, 1, 0)

TO

$oIE = _IECreate ("https://websrv01.physician-to-go.net/proxy.cgi/off/home/login.htm", 1, 1, 1)

which will do the same as a WinWaitActive?

Where can I see the documentation for all the parameters for the _IECreate function?

Uh oh, here we go...

Dog ate your help file?!

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Uh oh, here we go...

Dog ate your help file?!

:)

ROFL, it is worth mentioning that you'll find the _IE functions (like _IECreate, don't forget the underscore!) pretty easily in the Index tab, otherwise you'll want to look under User Defined Functions if looking in the Contents tab.

Edited by exodius

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  
Followers 0