Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting a URL from the currently active browser
Message
From
08/11/1999 09:50:29
 
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00288323
Message ID:
00288414
Views:
14
>I believe I am asking this question under the right catagory. Hi all. Using automation or an API call, I would like to extract the URL from the currently open browser (probably IE5) - I have spent an entirely frustrating and fruitless afternoon searching through the so-called help provided in the MSDN library and have come to terms with the fact that I do not even know where to look.

Did you fire the browser from inside VFP? If so, you may be able to use the WebBrowser ActiveX control to launch the browser, in which case the whole IE5 automation model is exposed - you can even hook VFP code to Browser Events this way using VFPCOM to link custom class methods to exposed events in the browser.

If not, then your best chance of doing this would be to use the Shell Object (requires that all systems have SHELL32.DLL at version 4.71 or later, not a problem with IE 4 or 5, but NetScrape gives you no assurance of this and doesn't share the InternetExplorer Object characteristics you can exploit from Shell.Application...)

Try something like:
oShellObj = CREATEOBJ('Shell.Application')
oShWinColl = oShellObj.Windows()
FOR EACH oItem IN oShWinColl
   ? oItem.LocationURL
ENDFOR
If you want to explicitly iterate through the members of the collection rather than using FOR EACH, the collection membership is 0 indexed, so the first member would be oShWinColl.item[0].

You'll want to examine the InternetExplorer object in detail, since there are a ton and a half of methods, properties and embedded objects. You'll find that you can navigate, check status, kill the instance, etc. Hooking to events there is trickier, but can be done with VFPCOM and custom VFP classes. Some specific properties you'll want to examine include Offline, RegisterAsBrowser, ReadyState and TopLevelContainer.

As for the 'so-called help' in the MSDN, you can find the gory details for this stuff under 'Shell Object' for the Shell.Application object model, with a link there under its Windows method to the 'ShellWindows Object', which is a collection of current InternetExplorer objects (and you can instance new ones from there, too!) The InternetExplorer object is strangely enough under the heading of (shock) 'InternetExplorer Object'... with apologies for the sarcasm; it's early and I haven't had nearly enough coffe this morning!

The key here was to know what you wanted to do, and what made it do it. The MSDN is a really pretty exhaustive reference, which is about as useless as an encyclopedia if you don't know what you're looking for...
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform