How can I retrieve information about the current address of the current Internet Explorer window (opened by the end-user) from VB? mail to pietcio@libero.it
I don't know any clean way of doing this but the first thing that comes to mind is to enumerate all the windows to generate a list of all the open Internet Explorer Windows with their respective handles.(If you have the code to enumerate windows, you'll see how to seperate them) Next get the handle to the current foreground window with the get-foreground-window API, and compare this handle to your list to find which of the Internet Explorer Windows matches(is) the foreground window. Then you would Enumerate this window and all its child windows. Once you have this list, you can determine which window is the address bar, and then use the SendMessage API to grab the text from this window. Might sound like a lot of work but it really wouldn't take too long. Sorry I don't have my resources with me so I can't hack up an example for you. Learn how to enumerate windows and you'd probably be all set from that point. Maybe I can post an example later. Hope that helps.
Just had an after thought - my answer was unnecessarily complicated. What it boils down to is that if the ForeGround Window is an Internet Explorer Window, then you can Enumerate this window and all its child windows to retrieve the handle to the address bar and then use the SendMessage API to retrieve the text from that window. If the foreground window is not an Internet Explorer Window(in cases where the user may have clicked on a different window at the point where you want this information) then this approach won't work and I'm not sure how you'd get this information. One way would be to monitor all the windows and always keep track of which Internet Explorer window was the last one opened and this should be the address you're looking for.
I've tried to use ForegroundWindow() API function and it works. It returns the handle of the window the user is working with. But how can I exactly know if the current handle (of the previously enumerated windows) is just the address bar handle? Is there a property I can look at?
I've thought also in this way:
I've declared an InternetExplorer object
Dim mIE as InternetExplorer
Set mIE = New InternetExplorer
Obviously mIE has got its own handle. Can I change this handle with the handle of the current Internet Explorer window the user is working with? I wonder I cannot do it.
But if I can, mIE has got a property which retrieves the current URL: mIE.LocationURL()
But I'm sure I can't do it. So I'm more interested to know how can I be sure the handle retrieved is the Internet Explorer address bar handle. mail to pietcio@libero.it
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.