Sign in to follow this  
Followers 0
quinthar

Right way to fill out name/password dialog from "HTTP Basic" authentication?

6 posts in this topic

What's the proper way to fill out the name/password dialog that appears when you visit a webpage protected with HTTP authentication? For example, if I do:

#include <IE.au3>
$ie = _IECreate( "http://www.pagetutor.com/keeper/mystash/secretstuff.html" );
MsgBox( 0, "Hello", "World" );

It opens up the browser, and the browser pops open a name/password dialog. But the script hangs while waiting for that input (in other words, _IECreate() blocks until the page finishes loading). Thus I can't script the name/password dialog directly (because the script is hung until the dialog goes away).

One way is to set the $f_wait parameter of _IECreate() to 0 so that the function returns immediately; then I can script the dialog directly. And then perhaps I can call _IECreate() again (with $f_tryAttach=1 and to attach back to the page and $f_wait=1 to wait for the page to load). But I haven't quite worked this out, and it feels very messy.

Is there a more straightforward way to open a webpage that prompts with a name/password dialog?

Thanks!

-david

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

A lot of times that pop-up window is a regular windows application. If you use the AU2info tool within SciTe on that pop-up I bet you will find that the fields and buttons are all things you can interact with using normal AutoIt functions.

The problem becomes that your script is paused waiting for that page to load, and the page is waiting for a successful password before it can load.

One way around that is (before you try to open the page) to create and then run another script that will just wait around for the password pop-up and fill it out when it shows up. I'll see if I can scrounge up an example for you.

Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

Thanks SpookMeister, that's a clever approach. I'm currently just using _IECreate() with f_wait=0, then I can script the username/password dialog as normal. When done, I just call _IELoadWait() on the original window, and that seems to do the trick. All told, pretty straightforward; was just wondering if there was some special command that I was missing that did it all in one line. Thanks!

Share this post


Link to post
Share on other sites

Wow, 5 posts in 7 and a half years...

How on earth did you remember your password (or even what info you used when you first signed up) after all that time? :)


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

Haha, AutoIt was always in the toolbox but I never quite had the need for it. Until now, that is... :)

Share this post


Link to post
Share on other sites

Thanks SpookMeister, that's a clever approach. I'm currently just using _IECreate() with f_wait=0, then I can script the username/password dialog as normal. When done, I just call _IELoadWait() on the original window, and that seems to do the trick. All told, pretty straightforward; was just wondering if there was some special command that I was missing that did it all in one line. Thanks!

Hi Quinthar,

I am also facing a similar issue where I am trying to open a URL and a username and password dialog box opens. Now I am not sure how to send the username and password to this dialog box. Could you please share your code.

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