Open Browser Window and get its Handle

rbulph

Junior Contributor
Joined
Feb 17, 2003
Messages
397
How can I open a web page and then get the handle of the window it's opened in? I've tried the following as a start, but, although the web page opens OK, k is always Nothing.

Code:
 Dim k As System.Diagnostics.Process = Process.Start("http://www.google.com")
 
Process.Start only returns a process object if it has to create a new process, there is a good chance that there is already a web browser open and this process will be reused.

Depending on what you are trying to do (and if you want to honour the users' browser choice or not) you could always add a reference to IE and use that...
 
Even if I close down all browser windows before running this line of code, k is still Nothing.

I'm trying to log-in to an account of mine automatically at a certain time of day. I have Firefox as my default browser which has the advantage that my username and password are completed automatically and all I have to do is click the button for logging in. I want the handle of the window so that I can ensure that it is the foreground window and I can click on the button (which I can do automatically). I suppose I could just note what the text of the log-in window is and use FindWindow, but it would seem better if I can get the handle from when I open the page, because the text might change in time.
 
Beastux. I did what you suggested, and now its working like a champ. I cant say though that I understood much of what I was doing when I was following your recipe.

Now, if only the reverse could be done, i.e. have Firefox open a compose window in Thunderbird when I click on an email address in a web page. At this point Im only getting an error message mailto is not a registered protocol. Any suggestions?
 
Beastux. I did what you suggested, and now its working like a champ. I cant say though that I understood much of what I was doing when I was following your recipe.

Now, if only the reverse could be done, i.e. have Firefox open a compose window in Thunderbird when I click on an email address in a web page. At this point Im only getting an error message mailto is not a registered protocol. Any suggestions?

Have you posted this in the wrong thread?
 
Back
Top