Jump to content

Unable to get _IENavigate Working Properly


 Share

Recommended Posts

I've been having problems with _IENavigate on several pages, where I can load the first page with _IECreate() or _IENavigate(), but any _IENavigate() commands that follow won't load. It's not every website, but I've run into the problem multiple times now and the only fix I'm able to come up with is having Send() directly edit the address bar (which is something I'm looking to avoid).

Here's a sample of code that I'm having issues with.

#include <IE.au3>
#RequireAdmin

Global $oIE

Func Login()
 Local $loginUN = IniRead("settings.ini", "Login", "User", "Default")
 Local $loginPW = IniRead("settings.ini", "Login", "Pass", "Default")

 $oIE = _IECreate("http://www.website.com/")
 Local $pTitle = WinGetTitle("[ACTIVE]")

 If $pTitle = ("Website Login - Internet Explorer") Then
  Sleep(500)
  Local $oForm = _IEFormGetObjByName($oIE, "form1")
  Local $oText = _IEFormElementGetObjByName($oForm, "user")
  _IEFormElementSetValue($oText, $loginUN)
  Sleep(500)
  Local $oText = _IEFormElementGetObjByName($oForm, "password")
  _IEFormElementSetValue($oText, $loginPW)
  Sleep(500)
  Send ("{Enter}")
 EndIf

; Now we're logged into the website, so let's navigate to the next page!

_IENavigate ($oIE, "http://www.website.com/next-page", 0)
EndFunc

Login()

I've tried everything I can think of and I've looked and looked through the search results on these forums, but I can't find a solution. What am I doing wrong, and how can I fix this?

Edited by 4b0082
Link to comment
Share on other sites

All we know thus far is that it doesn't work, which isn't very helpful.

Run your script in Scite and post the results from the output window.

 

I'm not getting any results other than the start of the script; it just infinitely hangs and never navigates to the next page. At one point I was getting "--> IE.au3 T3.0-1 Error from function _IENavigate, $_IEStatus_COMError (-2147352567)" but I've reorganized the code into what you see above and now I don't see any errors regardless of wait time.

Is there some kind of work-around I can use besides using a Send() command? I want my script to be completely injection based to keep it idiot proof for users who might click away from the browser (and I'm going to recode it to be hidden into a GUI later down the road, so I see using Send causing problems.)

Edit: Okay, here's something interesting I just discovered. If I open a new tab after running my script (manually hitting ctrl+t), the script will continue to use _IENavigate without any problems on the previous tab that was already open. My script completes, no errors.

I'm not sure if this is something that's been observed before, because I haven't read anything about it when I was hunting for solutions.

Edited by 4b0082
Link to comment
Share on other sites

So far the best solution I've found is just placing this into my code.

$oIE.Navigate2('http://www.website.com/new-page/', 0x0800) ; Open page in new tab.
Send ("^{TAB}^w") ; Switch to original tab and close it, leaving the new page as the only open page.

It feels kind of gritty, but it's better than nothing. I'd still love to hear some other suggestions if anyone has any, thanks!

Link to comment
Share on other sites

So far the best solution I've found is just placing this into my code.

$oIE.Navigate2('http://www.website.com/new-page/', 0x0800) ; Open page in new tab.
Send ("^{TAB}^w") ; Switch to original tab and close it, leaving the new page as the only open page.

It feels kind of gritty, but it's better than nothing. I'd still love to hear some other suggestions if anyone has any, thanks!

 

I wanted to add one more thing (edit isn't available anymore). If you use this code, remove the ^{TAB} from the Send command, it's not needed. "Navigate2" opens the new tab without switching over to it, so if you just use Send("^w") you'll close the dead tab and automatically jump to the new one.

Hope this helps someone out.

Link to comment
Share on other sites

  • 5 weeks later...

I actually was still having problems with this and put the project on hold to work on something else, so I never came up with a real solid solution.

$oIE.Navigate2("http://website.com", 0x1000)

This is what I was using and it seemed to work sometimes, but because it wasn't working all the time I just abandoned it and went with this instead. It's not as pretty, but it works.

$oIE = _IECreate("http://www.link-1.com")
   Sleep(500)
   Send("^w")
   Sleep(500)
 $oIE = _IECreate("http://www.link-2.com")
   Sleep(500)
   Send("^w")
   Sleep(500)
 $oIE = _IECreate("http://www.link-3.com")
   Sleep(500)
   Send("^w")
   Sleep(500)

Maybe someone else has some better ideas. Sorry.  >_<

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...