Is there an API that can tell you the URL of the IE window that you have currently open?

thereds

Diamond Member
Apr 4, 2000
7,886
0
0
You can get the title of the IE window. Thats simple enough.

How about the URL of that IE window thats currently on some webpage?
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
I assume you are getting the title through an HWND?

The easiest way would be to try to get the URL from the Address Combobox. You can get the information from Spy++ (comes with visual studio)


You can also get it from the IWebborwser2 interface but obtaining that interface requires a lot of work with COM.
 

thereds

Diamond Member
Apr 4, 2000
7,886
0
0
I'm using Powebuilder to develop this app I'm working on...so I'm not sure of Spy++ compatibility.

Any ideas?
 

juiio

Golden Member
Feb 28, 2000
1,433
4
81
You don't need Spy++ to do this. It just helps so that you can see what you're looking for in the end. Here is the relevant part of the window heirarchy for my IE window that has me replying to this thread:

Caption: "Replying to a Message - Microsoft Internet Explorer" Class: IEFrame
|-->Caption: "" Class: WorkerW
.....|-->Caption: "" Class: ReBarWindow32
..........|-->Caption: "" Class: ComboBoxEx32
...............|-->Caption: "" Class: ComboBox
....................|-->Caption:"" Class: Edit

That edit box is the one that contains the URL. Using FindWindow and FindWindowEx, you can get the handle to that edit box. Then you can just get the text from that edit box.

Of course, there might be an easier way to do this. If you get the Internet Explorer SDK, there is probably an easier way.
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
No, you don't. FindWindow and FindWindowEx both accept just a class name to get the HWND. Are you planning on having a single instance of IE open? If not, I believe it returns the HWND to the instance of the class with the highest z-order. You might also look at EnumWindows if you want to permute all the windows and process only those with the IEFrame class name, or perhaps only those with a certain window text.