Jump to content

error when opening IE browser


burton
 Share

Recommended Posts

The following script used to work before updating to Windows XP Pro, AutoIt v3 and IE7... so I dont know which update caused this error:

"(Null) could not be found. Make sure name is correct any retry. Click on Start and Search to search for a file"

Here is my code:

run ("D:\Programme\Internet Explorer\IEXPLORE.EXE")
WinWaitActive("Google")
Send("!S")
Opt("WinWaitDelay", 1500)
Send("www.WEBSITE.php")
Opt("WinWaitDelay", 2500)
Send("{ENTER}")
WinWaitActive("WINDOW_TITLE")
Opt("WinWaitDelay", 2500)
Send("{TAB 2}")
Send("ID_NR")
Sleep (3000)
Send("{TAB}")
Send("PASSWORD")
Send("{ENTER}")
;Opt("WinWaitDelay", 2500)
;WinSetState("WINDOW_TITLE", "", @SW_RESTORE)
;WinSetState("WINDOW_TITLE", "", @SW_MAXIMIZE)
Link to comment
Share on other sites

As you've found, that's a really tough way to automate IE. Try the _IE* functions from Dale's IE.au3 UDF.

:)

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

could someone please rewrite the code for me so it works? I am just a novice at this.... many thanks in advance :">

...and will stay a novice if you don't do it yourself. Or, could try out the Rent-A-Coder link in my sig. ;)

Crack open the help file and check out the example script under _IECreate(). That will get you started. Post what you've got when you get stuck and you'll get lots of help.

:)

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

OK I got my IE browser set correctly to the requested website.

How do I now get to access the first input field in the browser? Must this be done by _IEDocInsertText ?

I used to do it the simple way by adding the amount of TABS it needed, but this doesnt seem to work anymore in the latest version!

Link to comment
Share on other sites

OK I got my IE browser set correctly to the requested website.

How do I now get to access the first input field in the browser? Must this be done by _IEDocInsertText ?

I used to do it the simple way by adding the amount of TABS it needed, but this doesnt seem to work anymore in the latest version!

You have two ways to go:

1. Use the DOM objects with _IE* functions from the IE UDF. This is more complicated, but much more powerful and reliable (worth the learning curve).

2. Use the window with ControlSend() functions. This is easier, but not as reliable.

If you want to go with 2. (since you mention doing TABS before), then:

a. first get the handle of the window with WinGetHandle() or _IEPropertyGet($oIE, "hwnd")

b. second, make sure the IE window is active with WinActivate()/WinWaitActive()

c. Use ControlSend() with the window handle and blank control ID to send your TABS, etc.

Again, if you get stuck, post your code and you'll get help.

:)

P.S. An important point is that these methods are not mutually exclusive. You can do both with the same window. Open/Navigate/Wait for done with _IE* functions, then TAB around and fill in inputs with Win/Control functions, and then submit with _IEFormSubmit() would be one example.

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

OK i am trying the ControlSend method.

#include <IE.au3>
$oIE = _IECreate ("www.WEBSITE.php")
WinWaitActive("WINDOW TITLE")
WinSetState("WINDOW TITLE", "", @SW_MAXIMIZE)
ControlSend("WINDOW TITLE", "", "romo", "USER ID")
Sleep (3000)
Send("{TAB}")
Send("PASSWORD")
Send("{ENTER}")

The cursor doesnt move to the input field though and no text is inserted. So it doesnt go to the right section in the browser. Here is some code from the source:

<form method="post" action="romo.php" enctype="multipart/form-data" name="romo">

function login() {
      document.forms['romo'].pin.value = document.forms['romo'].pin2.value;
      document.forms['romo'].password.value = document.forms['romo'].password2.value;
      document.forms['romo'].pin2.value = "";
      document.forms['romo'].password2.value = "";
Edited by burton
Link to comment
Share on other sites

Since you don't want to learn the DOM methods yet, try it this way:

#include <IE.au3>

; Open web page
$oIE = _IECreate("www.WEBSITE.php")

; using handle will be more reliable than "WINDOW TITLE"
$hIE = _IEPropertyGet($oIE, "hwnd")
WinActivate($hIE)
WinWaitActive($hIE)
WinSetState($hIE, "", @SW_MAXIMIZE)
Sleep(1000) ; Sleeps are only to make sure you can follow the action visually

; blank ControlID to just send it to the window, "romo" is not a controlID
ControlSend($hIE, "", "", "USER ID")
Sleep(1000)
ControlSend($hIE, "", "", "{TAB}")
Sleep(1000)
ControlSend($hIE, "", "", "PASSWORD")
Sleep(1000)
ControlSend($hIE, "", "", "{ENTER}")

:)

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

The browser DOM knows about 'romo', the win32 API used by ControlSend does not.

There are examples in the helpfile nearly identical to this. Here is an example modified roughly to your page based on what you have shown:

$oForm = _IEFormGetObjByName($oIE, "romo")
$oPin1 = _IEFormElementGetObjByName($oForm, "pin1")
$oPin2 = _IEFormElementGetObjByName($oForm, "pin2")
_IEFormElementSetValue($oPin1, "your-username")
_IEFormElementSetValue($oPin2, "your-password")
_IEFormSubmit($oForm)

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

Since you don't want to learn the DOM methods yet, try it this way:

#include <IE.au3>

; Open web page
$oIE = _IECreate("www.WEBSITE.php")

; using handle will be more reliable than "WINDOW TITLE"
$hIE = _IEPropertyGet($oIE, "hwnd")
WinActivate($hIE)
WinWaitActive($hIE)
WinSetState($hIE, "", @SW_MAXIMIZE)
Sleep(1000) ; Sleeps are only to make sure you can follow the action visually

; blank ControlID to just send it to the window, "romo" is not a controlID
ControlSend($hIE, "", "", "USER ID")
Sleep(1000)
ControlSend($hIE, "", "", "{TAB}")
Sleep(1000)
ControlSend($hIE, "", "", "PASSWORD")
Sleep(1000)
ControlSend($hIE, "", "", "{ENTER}")

:)

Thank you... but this does not send the curser to the field where the USER ID ist within the browser?
Link to comment
Share on other sites

The browser DOM knows about 'romo', the win32 API used by ControlSend does not.

There are examples in the helpfile nearly identical to this. Here is an example modified roughly to your page based on what you have shown:

$oForm = _IEFormGetObjByName($oIE, "romo")
$oPin1 = _IEFormElementGetObjByName($oForm, "pin1")
$oPin2 = _IEFormElementGetObjByName($oForm, "pin2")
_IEFormElementSetValue($oPin1, "your-username")
_IEFormElementSetValue($oPin2, "your-password")
_IEFormSubmit($oForm)

Dale

Thank you... this seemed to work for the pin2, but that came in the first field. So I tried Send("{TAB}") to go to next input field, but the password then came in the address bar (at the top!) instead of to the next field.

Is that because the TAB is not used beforehand, so it is as if when you open a browser and press TAB it just goes to the url at the top?

Link to comment
Share on other sites

_IEFormSubmit($oForm)

OK - I got the correct syntax, now it is just the above that isnt correct. There is a "Log-in" link to click on, whereas the above command just tries to submit a form.

The log-in command will be somewhere within this code:

<td valign="center"><a href="java script:void login();" onmouseover="window.status='Log-in'; return true;" onmouseout="window.status=''; return true;" style="font-weight: bold">log-in</a></td>
               <td><img src="images/blank.gif" width="5" height="1"></td>
               <td valign="center"><a href="java script:void login();" onmouseover="window.status='Log-in'; return true;" onmouseout="window.status=''; return true;"><img src="images/b_arrow.gif" width="5" height="9" border="0"></a></td>
               <td><img src="images/blank.gif" width="150" height="1"></td>
               <td valign="center"><a href="java script:void windowclose()" style="font-weight: bold">Close</a></td>
Edited by burton
Link to comment
Share on other sites

Based on this HTML:

<a href="java script:void login();" onmouseover="window.status='Log-in'; return true;" onmouseout="window.status=''; return true;" style="font-weight: bold">log-in</a>

You can try _IELinkClickByText($oIE, "log-in")

If that isn't the answer, you'll need to dig into the helpfile and the _IE functions and examples -- or not. If you choose to go this way, I'd suggest you try the free DebugBar you'll find in my sig to make it easier to understand what you are working with.

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...