Grabbing the URL outof IE's Adres-bar - How to ? 
Author Message
 Grabbing the URL outof IE's Adres-bar - How to ?

Hello All,

  I'm working on a trinket that needs the current URL of a page displayed in
IE.  I thought I could do that by sending a "GetWindowTextA" (user32.dll)
message to that object, thus retrieving it's textual content's.

Alas, All requests to any of the components return with a False result (and
ofcourse no textual content).

Does anyone know of a way to retrieve the URL-information outof IE ?

Regards,
  Rudy Wieser



Fri, 23 Jul 2004 16:18:48 GMT  
 Grabbing the URL outof IE's Adres-bar - How to ?
Here's a way. In your case, you need to supply the hWnd of the IE child
window with the window class of "Edit". If you need help with that, check
out the FindWindow and EnumChildWindows API functions or post back.

Public Function WindowText(hWnd As Long) As String

   'retrieve text from within window of specified hWnd
   Const WM_GETTEXT = &HD
   Const WM_GETTEXTLENGTH = &HE
   Dim Textlen As Long, Text As String

   Textlen = SendMessage(hWnd, WM_GETTEXTLENGTH, 0, 0)
   If Textlen > 0 Then
      Textlen = Textlen + 1
      Text = Space(Textlen)
      Textlen = SendMessage(hWnd, WM_GETTEXT, Textlen, ByVal Text)
      WindowText = Left(Text, Textlen)
   Else
      WindowText = ""
   End If

End Function


Quote:
> Hello All,

>   I'm working on a trinket that needs the current URL of a page displayed
in
> IE.  I thought I could do that by sending a "GetWindowTextA" (user32.dll)
> message to that object, thus retrieving it's textual content's.

> Alas, All requests to any of the components return with a False result
(and
> ofcourse no textual content).

> Does anyone know of a way to retrieve the URL-information outof IE ?

> Regards,
>   Rudy Wieser



Fri, 23 Jul 2004 21:05:42 GMT  
 Grabbing the URL outof IE's Adres-bar - How to ?
http://www.mvps.org/access/api/api0051.htm
Quote:

> Hello All,

>   I'm working on a trinket that needs the current URL of a page displayed in
> IE.  I thought I could do that by sending a "GetWindowTextA" (user32.dll)
> message to that object, thus retrieving it's textual content's.

> Alas, All requests to any of the components return with a False result (and
> ofcourse no textual content).

> Does anyone know of a way to retrieve the URL-information outof IE ?

> Regards,
>   Rudy Wieser



Sat, 24 Jul 2004 01:29:27 GMT  
 Grabbing the URL outof IE's Adres-bar - How to ?


Hello Hugh,

  That's a short, sweet piece of code down below.  And yes, I did find the
hWnd of the box that contains the URL (there are actually *two* that contain
it).

The code that I used to search for the hWnd of the URL-box uses, just as you
described, the FindWindow and EnumChildWindows.  After that, I used
FindWindowExA to zoom-in on the found box. It codes easier.

One thing I still do not understand is why GetWindowText did not work.  Oh,
well, not too important, but it keeps on nagging me ...

Thanks for your response

Regards,
  Rudy Wieser

Quote:
> Here's a way. In your case, you need to supply the hWnd of the IE child
> window with the window class of "Edit". If you need help with that, check
> out the FindWindow and EnumChildWindows API functions or post back.

> Public Function WindowText(hWnd As Long) As String

>    'retrieve text from within window of specified hWnd
>    Const WM_GETTEXT = &HD
>    Const WM_GETTEXTLENGTH = &HE
>    Dim Textlen As Long, Text As String

>    Textlen = SendMessage(hWnd, WM_GETTEXTLENGTH, 0, 0)
>    If Textlen > 0 Then
>       Textlen = Textlen + 1
>       Text = Space(Textlen)
>       Textlen = SendMessage(hWnd, WM_GETTEXT, Textlen, ByVal Text)
>       WindowText = Left(Text, Textlen)
>    Else
>       WindowText = ""
>    End If

> End Function



> > Hello All,

> >   I'm working on a trinket that needs the current URL of a page
displayed
> in
> > IE.  I thought I could do that by sending a "GetWindowTextA"
(user32.dll)
> > message to that object, thus retrieving it's textual content's.

> > Alas, All requests to any of the components return with a False result
> (and
> > ofcourse no textual content).

> > Does anyone know of a way to retrieve the URL-information outof IE ?

> > Regards,
> >   Rudy Wieser



Sat, 24 Jul 2004 02:59:21 GMT  
 Grabbing the URL outof IE's Adres-bar - How to ?
Hi Rudy ... see in-line


Quote:


>   That's a short, sweet piece of code down below.  And yes, I did find the
> hWnd of the box that contains the URL (there are actually *two* that
contain
> it).

The other is probably the "list" part of the combobox

Quote:

> The code that I used to search for the hWnd of the URL-box uses, just as
you
> described, the FindWindow and EnumChildWindows.  After that, I used
> FindWindowExA to zoom-in on the found box. It codes easier.

> One thing I still do not understand is why GetWindowText did not work.
Oh,
> well, not too important, but it keeps on nagging me ...

I may be wrong, but I believe that API function only retrieves "caption"s
from controls


Sat, 24 Jul 2004 03:58:49 GMT  
 Grabbing the URL outof IE's Adres-bar - How to ?



Quote:
> Hi Rudy ... see in-line

Hello Hugh,

Quote:




> >   That's a short, sweet piece of code down below.  And yes,
> > I did find the hWnd of the box that contains the URL (there
> > are actually *two* that contain it).

> The other is probably the "list" part of the combobox

You got it !  That's exacly the place where I found it.

Quote:
> > The code that I used to search for the hWnd of the URL-box
> > uses, just as you described, the FindWindow and EnumChildWindows.
> > After that, I used FindWindowExA to zoom-in on the found box.
> > It codes easier.

> > One thing I still do not understand is why GetWindowText did not work.
> > Oh, well, not too important, but it keeps on nagging me ...

> I may be wrong, but I believe that API function only retrieves "caption"s
> from controls

I thought about that one too, but I'm allso trying my best at
Windows-assembly, and one of the steps I did was to try to place a Text-box
on the screen by itself (not within a Frame or Dialog-box I mean).  Windows
granted my request :-) , but whatever I typed into the box was reflected
into it's caption ...  It made me think that the caption of a TextBox and
its Text where one-and-the-same.  Now I have to Re-think it ... :-)

Regards,
  Rudy Wieser



Sat, 24 Jul 2004 17:27:33 GMT  
 Grabbing the URL outof IE's Adres-bar - How to ?
GetWindowText is in fact the Caption property.  Thing is, some windows don't
use it and store the data elsewhere.  i.e. the Start button's window text
does not contain "Start".  It's painted on manually.


Quote:



> > Hi Rudy ... see in-line

> Hello Hugh,





> > >   That's a short, sweet piece of code down below.  And yes,
> > > I did find the hWnd of the box that contains the URL (there
> > > are actually *two* that contain it).

> > The other is probably the "list" part of the combobox

> You got it !  That's exacly the place where I found it.

> > > The code that I used to search for the hWnd of the URL-box
> > > uses, just as you described, the FindWindow and EnumChildWindows.
> > > After that, I used FindWindowExA to zoom-in on the found box.
> > > It codes easier.

> > > One thing I still do not understand is why GetWindowText did not work.
> > > Oh, well, not too important, but it keeps on nagging me ...

> > I may be wrong, but I believe that API function only retrieves
"caption"s
> > from controls

> I thought about that one too, but I'm allso trying my best at
> Windows-assembly, and one of the steps I did was to try to place a
Text-box
> on the screen by itself (not within a Frame or Dialog-box I mean).
Windows
> granted my request :-) , but whatever I typed into the box was reflected
> into it's caption ...  It made me think that the caption of a TextBox and
> its Text where one-and-the-same.  Now I have to Re-think it ... :-)

> Regards,
>   Rudy Wieser



Sat, 24 Jul 2004 20:23:37 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Grab IE Address Bar url

2. grabbing url's

3. Grab the browser's URL?

4. IE Bar Quick Question: Window URL Location

5. IE Bar Quick Question: Window URL Location

6. Launch IE or Grab IE Instance

7. automated navigation between URL's using one instance of IE

8. grabbing url and opening in Excel?

9. Grab URL and send as HTML mail

10. Bookmarked URL Works, Saved URL String Doesn't

11. Extract URL Links from Page, Navigate to these URL's and Extract E-Mail

12. Screen Print/Grab from within IE

 

 
Powered by phpBB® Forum Software