473,387 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Caturing ACTIVE IE Url

I am looking to capture the URL of the ACTIVE IE window.

How the heck can I determine which window is the active window.

Better yet how do I grab the URL of that particular window ?

I am searching and searching but see no VB samples of anything I want
to do.

I have a bit of code that will grab the URL but it grabs the URL of
ALL IE instances NOT just the active one , this includes things that
use the IE control, as was mentioned things like Kazza as well.

This .Net can be so damm frustrating sometimes, I mean I love the
power of it but all the code I wrote from VB4-VB6 is pretty much
useless and archane.

Im losing my hair on this one.....next week Ill be bald if I dont get
this figured out.

Chris
Nov 20 '05 #1
10 3989
> Im losing my hair on this one.....next week Ill be bald if I dont get
this figured out. heheheh :)
I have a bit of code that will grab the URL but it grabs the URL of
ALL IE instances NOT just the active one , this includes things that this code will help

ok, well it wont be done with the help of .net libs. But you can do it with
interoperating with win32api. now all you need to do is get the forground
window handle using GetForegroundWindow and than use the EnumChildWIndows
api to find the address window. You'll need to know its class which u'll get
from spy++ and than send it a WM_GETTEXT message to get the url written
inside it.
I hope this helps. But to save you from getting bald if you say I can try to
do it for you and post the actuall code in vb.net.

- Abubakar (not an MVP :) )

"Chris Wertman" <cw******@yahoo.com> wrote in message
news:14*************************@posting.google.co m... I am looking to capture the URL of the ACTIVE IE window.

How the heck can I determine which window is the active window.

Better yet how do I grab the URL of that particular window ?

I am searching and searching but see no VB samples of anything I want
to do.

I have a bit of code that will grab the URL but it grabs the URL of
ALL IE instances NOT just the active one , this includes things that
use the IE control, as was mentioned things like Kazza as well.

This .Net can be so damm frustrating sometimes, I mean I love the
power of it but all the code I wrote from VB4-VB6 is pretty much
useless and archane.

Im losing my hair on this one.....next week Ill be bald if I dont get
this figured out.

Chris


Nov 20 '05 #2
> Im losing my hair on this one.....next week Ill be bald if I dont get
this figured out. heheheh :)
I have a bit of code that will grab the URL but it grabs the URL of
ALL IE instances NOT just the active one , this includes things that this code will help

ok, well it wont be done with the help of .net libs. But you can do it with
interoperating with win32api. now all you need to do is get the forground
window handle using GetForegroundWindow and than use the EnumChildWIndows
api to find the address window. You'll need to know its class which u'll get
from spy++ and than send it a WM_GETTEXT message to get the url written
inside it.
I hope this helps. But to save you from getting bald if you say I can try to
do it for you and post the actuall code in vb.net.

- Abubakar (not an MVP :) )

"Chris Wertman" <cw******@yahoo.com> wrote in message
news:14*************************@posting.google.co m... I am looking to capture the URL of the ACTIVE IE window.

How the heck can I determine which window is the active window.

Better yet how do I grab the URL of that particular window ?

I am searching and searching but see no VB samples of anything I want
to do.

I have a bit of code that will grab the URL but it grabs the URL of
ALL IE instances NOT just the active one , this includes things that
use the IE control, as was mentioned things like Kazza as well.

This .Net can be so damm frustrating sometimes, I mean I love the
power of it but all the code I wrote from VB4-VB6 is pretty much
useless and archane.

Im losing my hair on this one.....next week Ill be bald if I dont get
this figured out.

Chris


Nov 20 '05 #3
I want to thank you for the direction, I was missing the
GetForegroundWindow
I didnt like having to go through all the other hoops so Ive
simplified it a bit here is the code for posterity and anyone else
looking to do what I have done. Basically it dosnet do anything except
say IE is not the Forground window unless it is triggered from and IE
add in since well IE will not be in the foreground :)

Im lazy thats part of why I enjoy programming so darn much (toung in
cheek) so I was basically too lazy to do all the things you suggested
so here is what I found works ......

Anyhoo here is the code.
Inherits System.Windows.Forms.Form
Private IEs As New SHDocVw.ShellWindows
Private IE As SHDocVw.InternetExplorer
Private Declare Function GetForegroundWindow Lib "user32" () As
Long
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim Ret As Long

For Each IE In IEs
'Here we will compare the ACTIVE IE.HWND
Ret = GetForegroundWindow()
If Ret = IE.HWND Then
MsgBox(IE.LocationURL)

Else

MsgBox("IE is not the foreground window the active
window is " & Ret & " the IE it is accessing is " & IE.HWND)
End If

Next

End Sub

Doing it this way there is no reason to "then use the EnumChildWIndows
api to find the address window. You'll need to know its class which
u'll get
from spy++ and than send it a WM_GETTEXT"

Thanks again

Chris


"Abubakar" <em**********@yahoo.com> wrote in message news:<O9*************@TK2MSFTNGP12.phx.gbl>...
Im losing my hair on this one.....next week Ill be bald if I dont get
this figured out.

heheheh :)
I have a bit of code that will grab the URL but it grabs the URL of
ALL IE instances NOT just the active one , this includes things that

this code will help

ok, well it wont be done with the help of .net libs. But you can do it with
interoperating with win32api. now all you need to do is get the forground
window handle using GetForegroundWindow and than use the EnumChildWIndows
api to find the address window. You'll need to know its class which u'll get
from spy++ and than send it a WM_GETTEXT message to get the url written
inside it.
I hope this helps. But to save you from getting bald if you say I can try to
do it for you and post the actuall code in vb.net.

- Abubakar (not an MVP :) )

"Chris Wertman" <cw******@yahoo.com> wrote in message
news:14*************************@posting.google.co m...
I am looking to capture the URL of the ACTIVE IE window.

How the heck can I determine which window is the active window.

Better yet how do I grab the URL of that particular window ?

I am searching and searching but see no VB samples of anything I want
to do.

I have a bit of code that will grab the URL but it grabs the URL of
ALL IE instances NOT just the active one , this includes things that
use the IE control, as was mentioned things like Kazza as well.

This .Net can be so damm frustrating sometimes, I mean I love the
power of it but all the code I wrote from VB4-VB6 is pretty much
useless and archane.

Im losing my hair on this one.....next week Ill be bald if I dont get
this figured out.

Chris

Nov 20 '05 #4
Whooppppsss I posted the wrong code.......oh well here is what works
as an IE add in.


Module Module1

Private IEs As New SHDocVw.ShellWindows
Private IE As SHDocVw.InternetExplorer
Private Declare Function GetForegroundWindow Lib "user32" () As
Int32


Sub Main()
Dim objWebClient As New WebClient
Dim objUTF8 As New UTF8Encoding

Dim Ret As Int32

For Each IE In IEs
'Here we will compare the ACTIVE IE.HWND
Ret = GetForegroundWindow()
If Ret = IE.HWND Then

MsgBox(IE.LocationURL)
End If

Next


End Sub

End Module

Have fun.....

cw******@yahoo.com (Chris Wertman) wrote in message news:<14**************************@posting.google. com>...
I want to thank you for the direction, I was missing the
GetForegroundWindow
I didnt like having to go through all the other hoops so Ive
simplified it a bit here is the code for posterity and anyone else
looking to do what I have done. Basically it dosnet do anything except
say IE is not the Forground window unless it is triggered from and IE
add in since well IE will not be in the foreground :)

Im lazy thats part of why I enjoy programming so darn much (toung in
cheek) so I was basically too lazy to do all the things you suggested
so here is what I found works ......

Anyhoo here is the code.
Inherits System.Windows.Forms.Form
Private IEs As New SHDocVw.ShellWindows
Private IE As SHDocVw.InternetExplorer
Private Declare Function GetForegroundWindow Lib "user32" () As
Long
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim Ret As Long

For Each IE In IEs
'Here we will compare the ACTIVE IE.HWND
Ret = GetForegroundWindow()
If Ret = IE.HWND Then
MsgBox(IE.LocationURL)

Else

MsgBox("IE is not the foreground window the active
window is " & Ret & " the IE it is accessing is " & IE.HWND)
End If

Next

End Sub

Doing it this way there is no reason to "then use the EnumChildWIndows
api to find the address window. You'll need to know its class which
u'll get
from spy++ and than send it a WM_GETTEXT"

Thanks again

Chris


"Abubakar" <em**********@yahoo.com> wrote in message news:<O9*************@TK2MSFTNGP12.phx.gbl>...
Im losing my hair on this one.....next week Ill be bald if I dont get
this figured out.

heheheh :)
I have a bit of code that will grab the URL but it grabs the URL of
ALL IE instances NOT just the active one , this includes things that

this code will help

ok, well it wont be done with the help of .net libs. But you can do it with
interoperating with win32api. now all you need to do is get the forground
window handle using GetForegroundWindow and than use the EnumChildWIndows
api to find the address window. You'll need to know its class which u'll get
from spy++ and than send it a WM_GETTEXT message to get the url written
inside it.
I hope this helps. But to save you from getting bald if you say I can try to
do it for you and post the actuall code in vb.net.

- Abubakar (not an MVP :) )

"Chris Wertman" <cw******@yahoo.com> wrote in message
news:14*************************@posting.google.co m...
I am looking to capture the URL of the ACTIVE IE window.

How the heck can I determine which window is the active window.

Better yet how do I grab the URL of that particular window ?

I am searching and searching but see no VB samples of anything I want
to do.

I have a bit of code that will grab the URL but it grabs the URL of
ALL IE instances NOT just the active one , this includes things that
use the IE control, as was mentioned things like Kazza as well.

This .Net can be so damm frustrating sometimes, I mean I love the
power of it but all the code I wrote from VB4-VB6 is pretty much
useless and archane.

Im losing my hair on this one.....next week Ill be bald if I dont get
this figured out.

Chris

Nov 20 '05 #5
Hi Chris,

I was the one who answered you in the other newsgroup.
What I do not know is how do you become your Docs, that can in a lot of ways
it can using streaming or using the axwebbrowser and create your own mini
IE.

To see an example of this download this than you have that minibrowser.

http://support.microsoft.com/?kbid=311303

There is also a little bit the mshtml in.

This is a link about mshtml do not think it is nice stuff, although very
effective

http://msdn.microsoft.com/library/de...ng/hosting.asp

And with this there are mostly 2 methodes, with nothing at the end and with
2 at the end, try to use the methods with a 2 at the end.

When you use this you have to set in the beginning Option Strict Off

When you are something further with it, ask again, mostly this questions are
answered in this newsgrou by Charles Law and when not than by me.

I hope this helps a little bit.

Cor




Nov 20 '05 #6
Here is the entire code to do what I am doing so far , I dont like how I
am doing the string replacment I would hink I could just grab it all in
a regular expression.

I am a little confused as to using th mshtml and how that would offer
any benifit over what I am doing now.

Here is how I am doing it.

Imports System.Text
Imports System.Net
Imports System.Text.RegularExpressions

Module Module1

Private IEs As New SHDocVw.ShellWindows
Private IE As SHDocVw.InternetExplorer
Private Declare Function GetForegroundWindow Lib "user32" () As
Int32

Sub Main()
Dim objWebClient As New WebClient
Dim objUTF8 As New UTF8Encoding

Dim Ret As Int32

For Each IE In IEs
'Here we will compare the ACTIVE IE.HWND
'Title is in this format
'<span class="header6">
'Tom Hawke (Orig. Title: the Link Boys)
'</span>

'Author is in this format
'
Ret = GetForegroundWindow()
If Ret = IE.HWND Then

Dim html As String =
objUTF8.GetString(objWebClient.DownloadData(IE.Loc ationURL))
'Multiple Regex here ?
Dim regex As New Regex("<span
class=""header6"">((.|\n)*?)</span>", RegexOptions.IgnoreCase)
Dim re As New Regex("<[^>]*>", RegexOptions.IgnoreCase)
Dim regex2 As New Regex("<b>Binding:</b>((.|\n)*?)<br>
<b>Publisher:", RegexOptions.IgnoreCase)

'Dim regex As New Regex("<b>Binding:</b>((.|\n)*?)<br>
<b>Publisher:", RegexOptions.IgnoreCase)
'MsgBox(IE.LocationURL)
' Dim Match = regex.Match(html)

Dim title, author, binding, condition As String
title = regex.Match(html).ToString
title = re.Replace(title, "")
binding = regex2.Match(html).ToString
binding = re.Replace(binding, "")
binding = Replace(binding, "Binding:", "")
binding = Replace(binding, "Publisher:", "")

MsgBox(Ret & Trim(title) & " " & binding)
End If

Next


End Sub

End Module

Any suggestions on how I could clean up the stripping of Title and
author would be appreciated.

Chris

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #7
Here is the entire code to do what I am doing so far , I dont like how I
am doing the string replacment I would hink I could just grab it all in
a regular expression.

I am a little confused as to using th mshtml and how that would offer
any benifit over what I am doing now.

Here is how I am doing it.

Imports System.Text
Imports System.Net
Imports System.Text.RegularExpressions

Module Module1

Private IEs As New SHDocVw.ShellWindows
Private IE As SHDocVw.InternetExplorer
Private Declare Function GetForegroundWindow Lib "user32" () As
Int32

Sub Main()
Dim objWebClient As New WebClient
Dim objUTF8 As New UTF8Encoding

Dim Ret As Int32

For Each IE In IEs
'Here we will compare the ACTIVE IE.HWND
'Title is in this format
'<span class="header6">
'Tom Hawke (Orig. Title: the Link Boys)
'</span>

'Author is in this format
'
Ret = GetForegroundWindow()
If Ret = IE.HWND Then

Dim html As String =
objUTF8.GetString(objWebClient.DownloadData(IE.Loc ationURL))
'Multiple Regex here ?
Dim regex As New Regex("<span
class=""header6"">((.|\n)*?)</span>", RegexOptions.IgnoreCase)
Dim re As New Regex("<[^>]*>", RegexOptions.IgnoreCase)
Dim regex2 As New Regex("<b>Binding:</b>((.|\n)*?)<br>
<b>Publisher:", RegexOptions.IgnoreCase)

'Dim regex As New Regex("<b>Binding:</b>((.|\n)*?)<br>
<b>Publisher:", RegexOptions.IgnoreCase)
'MsgBox(IE.LocationURL)
' Dim Match = regex.Match(html)

Dim title, author, binding, condition As String
title = regex.Match(html).ToString
title = re.Replace(title, "")
binding = regex2.Match(html).ToString
binding = re.Replace(binding, "")
binding = Replace(binding, "Binding:", "")
binding = Replace(binding, "Publisher:", "")

MsgBox(Ret & Trim(title) & " " & binding)
End If

Next


End Sub

End Module

Any suggestions on how I could clean up the stripping of Title and
author would be appreciated.

Chris

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #8
Hi Chris,

They made a document object model to make it able to extract a complete
webpage.
So why do you not use that?

Doing this with the regex is getting the horse after the cart.

Cor
Nov 20 '05 #9

Well I a wee bit confused about that, I read about it in another thread
as suggested and looked on the web but Im still at a loss.

I need to extract about 7 name value pairs , but how would the DOM know
what belongs to what as they are all on the same line and I do not
control the code on the other end.

Any help with an explanation of how the DOM works with something like
this would be appreciated.

Chris


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Philippe Poulard | last post by:
People that have a knowledge of XQuery, XSLT, Ant, JSP/PHP/ASP, Cocoon, XMLBeans, taglibs and many others should recognize any of them in "Active Tags". " Active Tags is a set of specifications...
3
by: Amit | last post by:
Hi when I try to run LIST ACTIVE DATABASES AT DBPARTITIONNUM <partnum> or LIST ACTIVE DATABASES GLOBAL, I always get an error message. Does anyone know why? I'm on v8 fp 5 output : db2 => list...
3
by: Kevin | last post by:
Is it possible to develop an Active Document Full Server or a Container application using C#? Thanks, Kevin.
3
by: Chris Wertman | last post by:
I am looking to capture the URL of the ACTIVE IE window. How the heck can I determine which window is the active window. Better yet how do I grab the URL of that particular window ? I am...
8
by: salad | last post by:
I was wondering how you handle active/inactive elements in a combo box. Let's say you have a combo box to select an employee. Joe Blow has been selected for many record however Joe has left the...
0
by: fblake | last post by:
FOR IMMEDIATE RELEASE Active Up expands ever popular product line Active Web.Controls 2007 V1, Active Cells V2 and Active AutoSuggest V1.0 Belgium (February 2007): Active Up today released...
0
by: fblake | last post by:
Belgium (April 2007): Active Up today released the latest version of their .NET email component suite, ActiveUp.MailSystem. ActiveUp.MailSystem is the (r)evolution of the popular ActiveMail...
0
by: fblake | last post by:
Belgium (June 2007): Active Up today released the latest version of their RTF and HTML converter control for .NET, Active RTF, ActiveUp.RTF V3 ActiveUp.RTF enables any developer to convert...
0
by: fblake | last post by:
Brussels, Belgium and Sunnyvale, Calif., – July 2007 – Active Up today announced today that it has entered into an agreement with Commtouch® (NASDAQ:CTCH) to license Anti-Spam and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.