Solved

Getting URL from an open browser

Posted on 1998-06-19
6
178 Views
Last Modified: 2010-05-03
I want to be able to get  a url (and maybe say the last 10 visited) from an open browser.. if no browser is open, then maybe just the last 10 visited.. is there any EASY way to do this?
0
Comment
Question by:sonix061998
  • 3
  • 2
6 Comments
 
LVL 9

Expert Comment

by:Dalin
ID: 1463808
sonix,
I have a way to get the current one. You can have it running and add it to a list.
However, it does not do anything if the browser is not open.
If you like, I will post that.
Regards
Dalin
0
 
LVL 1

Expert Comment

by:johnny_5
ID: 1463809
Well, that all depends on what browser now.... :)


0
 

Author Comment

by:sonix061998
ID: 1463810
Dalin,
  yes that would be EXCELLENT.  Thanks!

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:sonix061998
ID: 1463811
Dalin,
  yes that would be EXCELLENT.  Thanks!

0
 
LVL 9

Accepted Solution

by:
Dalin earned 100 total points
ID: 1463812
Sonix,
Here you are. See if this works for you(it assume you use NetScape and the caption start with "Netscape", you can adjust)
Regards
Dalin

    Copy these code to a module:

    Option Explicit

    Public Type ProcData
        AppHwnd As Long
        title As String
        Placement As String
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type

    Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As
    Long) As Long

    Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As
    Long
    Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal
    nMaxCount As Long) As Long
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As
    Long, lParam As Any) As Long

    Private Const WM_GETTEXT = &HD
    Private Const WM_GETTEXTLENGTH = &HE

    Private Const GW_CHILD = 5
    Private Const GW_HWNDNEXT = 2
    Private Const GW_HWNDFIRST = 0
    ' ***********************************************
    ' If this window is of the Edit class, return
    ' its contents. Otherwise search its children
    ' for an Edit object.
    ' ***********************************************
    Public Function EditInfo(window_hwnd As Long) As String
    Dim txt As String
    Dim buf As String
    Dim buflen As Long
    Dim child_hwnd As Long
    Dim children() As Long
    Dim num_children As Integer
    Dim i As Integer

        ' Get the class name.
        buflen = 256
        buf = Space$(buflen - 1)
        buflen = GetClassName(window_hwnd, buf, buflen)
        buf = Left$(buf, buflen)
         
        ' See if we found an Edit object.
        If buf = "Edit" Then
            EditInfo = WindowText(window_hwnd)
            Exit Function
        End If
         
        ' It's not an Edit object. Search the children.
        ' Make a list of the child windows.
        num_children = 0
        child_hwnd = GetWindow(window_hwnd, GW_CHILD)
        Do While child_hwnd <> 0
            num_children = num_children + 1
            ReDim Preserve children(1 To num_children)
            children(num_children) = child_hwnd
             
            child_hwnd = GetWindow(child_hwnd, GW_HWNDNEXT)
        Loop
         
        ' Get information on the child windows.
        For i = 1 To num_children
            txt = EditInfo(children(i))
            If txt <> "" Then Exit For
        Next i

        EditInfo = txt
    End Function
    ' ************************************************
    ' Return the text associated with the window.
    ' ************************************************
    Public Function WindowText(window_hwnd As Long) As String
    Dim txtlen As Long
    Dim txt As String

        WindowText = ""
        If window_hwnd = 0 Then Exit Function
         
        txtlen = SendMessage(window_hwnd, WM_GETTEXTLENGTH, 0, 0)
        If txtlen = 0 Then Exit Function
         
        txtlen = txtlen + 1
        txt = Space$(txtlen)
        txtlen = SendMessage(window_hwnd, WM_GETTEXT, txtlen, ByVal txt)
        WindowText = Left$(txt, txtlen)
    End Function


    Public Function EnumProc(ByVal app_hwnd As Long, ByVal lParam As Long) As Boolean
    Dim buf As String * 1024
    Dim title As String
    Dim length As Long

        ' Get the window's title.
        length = GetWindowText(app_hwnd, buf, Len(buf))
        title = Left$(buf, length)

        ' See if the title ends with " - Netscape".
        If Left$(title, 8) = "Netscape" Then
            ' This is it. Find the ComboBox information.
            frmWindowList.lblAddress = EditInfo(app_hwnd)

            ' Stop searching.
            EnumProc = 0
        Else
            ' Continue searching til find it.
            EnumProc = 1
        End If
    End Function

    in form1, drop a label name it lblAddress, and a command button name it cmdFindAddress,
    add code:

    Option Explicit

    Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Any, ByVal lParam As Long) As Long
    ' Start the enumeration.

    Private Sub cmdFindAddress_Click()
        lblAddress.Caption = ""
        EnumWindows AddressOf EnumProc, 0
    End Sub
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1463813
sonix,
you should name form1 to frmWindowList or make changes in the code to match your window name
Regards
Dalin
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 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

12 Experts available now in Live!

Get 1:1 Help Now