Reading Data From The Browser

  • Thread starter Thread starter emarvets
  • Start date Start date
E

emarvets

I'm working on a stand-alone winform app and could add a really cool
feature if I could just get the URL of the active tab in the active
browser window.

Note that the browser would have focus...my app just sits in the
background and based on the current URL, it would change the context
of information that would be displayed when the user returns focus to
me.

I haven't touched the IE API's in years, but know there has to be a
way. I doubt very seriously that FireFox does, but if anyone has any
ideas, it is more than appreciated.

Thanks,
Eric
 
On 24/04/2008 in message
<[email protected]>
I haven't touched the IE API's in years, but know there has to be a
way. I doubt very seriously that FireFox does, but if anyone has any
ideas, it is more than appreciated.

I use this to get the current URL in IE7:

public static string GetIEURL()
{
string strClassName = "IEFrame";
int intResult;
IntPtr ipChild;
IntPtr ipWindow = JDll.FindWindow(strClassName, IntPtr.Zero);
StringBuilder lpString = new StringBuilder(260);
if (ipWindow != IntPtr.Zero)
{
ipChild = JDll.FindWindowEx(ipWindow, IntPtr.Zero, "WorkerW",
IntPtr.Zero);
if (ipChild != IntPtr.Zero)
{
ipChild = JDll.FindWindowEx(ipChild, IntPtr.Zero, "ReBarWindow32",
IntPtr.Zero);
if (ipChild != IntPtr.Zero)
{
ipChild = JDll.FindWindowEx(ipChild, IntPtr.Zero, "Address Band
Root", IntPtr.Zero);//ComboBoxEx32
if (ipChild != IntPtr.Zero)
{
ipChild = JDll.FindWindowEx(ipChild, IntPtr.Zero, "ComboBoxEx32",
IntPtr.Zero);

if (ipChild != IntPtr.Zero)
{
intResult = JDll.SendMessage(ipChild, (int)WM.WM_GETTEXT, 260,
lpString);
}
}
}
}
}
return lpString.ToString();
}

If you want to keep it updated perhaps use a timer in your app?

You'll need to add some dll prototypes and constant definitions.
 
Back
Top