Solved

500 pts total cross posting question no takers yet..

Posted on 2004-10-18
6
172 Views
Last Modified: 2010-05-02
0
Comment
Question by:Informative
  • 4
  • 2
6 Comments
 
LVL 3

Author Comment

by:Informative
ID: 12351492
250 points still remain for an improvement over the ctrl-TAB ctrl-C sendkeys method to focus the address bar in explorer and copy the address to the clipboard as the best (only) means of grabbing this info programatically.
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 25 total points
ID: 12354585
Hi Informative,

Not sure I understand the question 100%, but if you need to grab the URL of the Internet Explorer that has focus then here is how to do it:

Option Explicit

Private Declare Function GetForegroundWindow Lib "user32" () As Long

Private Sub Timer1_Timer()
'
'From the Project->References menu, add a reference to "Microsoft Internet Controls"
'The following code gets the current URL of the IE with focus.
'
'See also: "How To Connect to a Running Instance of Internet Explorer"
'http://support.microsoft.com/default.aspx?sd=msdn&scid=kb%3Ben-us%3B176792
'
'
    Dim shWnds As New ShellWindows
    Dim ie As InternetExplorer
    Dim lhWnd As Long
    Dim sURL As String
   
    sURL = ""
   
    'Loop all the instances of IE and see if one has focus
    For Each ie In shWnds
        'Get the handle of the window with focus
        lhWnd = GetForegroundWindow()
        'See if any IE windows have the focus
        If (ie.hWnd = lhWnd) Then
            sURL = ie.LocationURL
        End If
    Next
   
    Debug.Print sURL
   
End Sub
0
 
LVL 3

Author Comment

by:Informative
ID: 12358776
This line gives me a user defined type not defined.  
Dim shWnds As New ShellWindows

Does it perhaps require a particular library in project references?
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 32

Expert Comment

by:Erick37
ID: 12359384
Yes,

From the Project->References menu, add a reference to "Microsoft Internet Controls"
0
 
LVL 3

Author Comment

by:Informative
ID: 12359520
Yes that works!  Excellent work.
0
 
LVL 3

Author Comment

by:Informative
ID: 12359536
Please go here and post a comment so I can award you those points too Eric37

http://experts-exchange.com/Web/Web_Languages/Q_21172808.html
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now