none
Get the active URL from IE-6 or 7 using C# code

    Question

  • Hi.

    The question is in the subject...

     

    How can I extract the active URL currently displayed on the browser using C# code? (note that for IE7, I need the 'selected-tab' URL).

     

    Any ideas...?

     

    Monday, February 18, 2008 5:33 PM

Answers

  • I can not post an example but i will try to give some pseudo code. basicly this code uses native code so you will need to DllImport it into a C# code.

     

    1. call FindWindowEX function o find the IE main window

    2. after you find it call the same function to get to the Edit control that holds the relevant text. with Spy you can get the ID of the window

    3. now it is easy to call GetWindowText to get the text in the editBox.

    Thursday, February 21, 2008 4:10 PM

All replies

  • Jump up...

     

    Anyone?

     

     

    Thursday, February 21, 2008 1:21 PM
  • you can have more then one explorer instance running so it is not crear witch text you need to extract.

     

    any way if you actuay know the exact instance you can:

    find it's control holding the text and call a getWindowtext on it.

    Thursday, February 21, 2008 1:45 PM
  • Assuming I have only one IE opened, could you post an example about how to do it?

     

    Thursday, February 21, 2008 3:27 PM
  • I can not post an example but i will try to give some pseudo code. basicly this code uses native code so you will need to DllImport it into a C# code.

     

    1. call FindWindowEX function o find the IE main window

    2. after you find it call the same function to get to the Edit control that holds the relevant text. with Spy you can get the ID of the window

    3. now it is easy to call GetWindowText to get the text in the editBox.

    Thursday, February 21, 2008 4:10 PM