HOW to GET ie title bar TEXT?

Is it possible to get Internet Explorer Title Bar Text ?
razaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MarineCommented:
yes its possible

Do you know how to use win API's ?
You will be needing 2 api calls to do this. One is FindWindow and the other one is getwindowtext
best of luck

0
st_steveCommented:
the comment by "Marine" applies to ALL windows...not just IE....and if you're trying to change the IE caption text (the one that reads " ....  - Microsoft Internet Explorer)...you can change that in the registry as well to suit your needs. the registry value is at:
 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main

Add a string value named "Window Title"
and change the value to whatever you want to appear on the title bar....make sure you restart IE

0
mhdhallakCommented:
In case you have a reference to Internet Explorer's dll file called:ShDocVW.dll, you can use the title change event to modify the title of the explorer's window.

The Syntax for this event looks like this:

Private Sub ie_TitleChange(ByVal Text As String)

End Sub
 
You can assign a string value to the Text argument to change the title text.

Hope that helps.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

crazymanCommented:
You may also find this useful..



Place a text box on form called
DDELink
And a command button called cmdGetUrls


Function GetCurrentNetscapeURL() As String
Dim commapos As Integer
On Error Resume Next
Dim urltitle As String
With DDELink
    .LinkMode = 0
    .LinkTopic = "Netscape|WWW_GetWindowInfo"
    .LinkItem = &HFFFFFFFF
    .LinkMode = 2
    .LinkRequest
    .LinkMode = 0
    Debug.Print .Text
    Debug.Print Left(.Text, 20)
    commapos = InStr(.Text, ",")
    GetCurrentNetscapeURL = Mid(.Text, 2, commapos - 3)
    urltitle = Mid(.Text, commapos + 2, Len(.Text) - (commapos + 2))
End With
End Function
Function GetCurrentIEURL() As String
Dim commapos As Integer
On Error Resume Next
Dim urltitle As String
With DDELink
    .LinkMode = 0
    .LinkTopic = "Iexplore|WWW_GetWindowInfo"
    .LinkItem = &HFFFFFFFF
    .LinkMode = 2
    .LinkRequest
    .LinkMode = 0
    Debug.Print .Text
    Debug.Print Left(.Text, 20)
    commapos = InStr(.Text, ",")
    GetCurrentIEURL = Mid(.Text, 2, commapos - 3)
    urltitle = Mid(.Text, commapos + 2, Len(.Text) - (commapos + 2))
End With
End Function

private sub cmdGetUrls_Click()
  msgbox getcurrentnetscapeurl
  msgbox getcurrentieurl
end sub

Cheers
0
razaAuthor Commented:
I don't want to change any title text.

What I m exactly trying to do is search for keywords "sex, nude, gay ,sexpix and etc" on to any internet explorer title bar to find out who is on prongraphic. I m try to get Alart message whoever goes on to any porn site..
0
MarineCommented:
Raza its more work then youthink. One thing you can use what i already suggest . Then you can make an array of these words  and compare them to the title bar. Why can't you just put a protection on IE which sites the users can view and can't view ? YOu can make it so they can't see x-rated sites.
0
crazymanCommented:
Raza mymethod will also tell you the current title if you modify it a bit....
0
Erick37Commented:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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 GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" _
    (ByVal hwnd As Long) As Long

Private Sub Command1_Click()
    Dim sBuffer As String
    Dim hWind As Long
    Dim lLen As Long
    'Find the Internet Explorer handle
    hWind = FindWindow("IEFRAME", vbNullString)
    If hWind <> 0 Then
        'Get the length of the window text
        lLen = GetWindowTextLength(hWind)
        sBuffer = String(lLen, Chr(0))
        'Get the title
        Call GetWindowText(hWind, sBuffer, lLen + 1)
        'Do something with the title
        Caption = sBuffer
    End If
End Sub
0
razaAuthor Commented:
If I have open more then one Internet Exploer it deson't show up all title or address. it just get one address or title of ie.
0
Erick37Commented:
Use EnumWindows to search for all IE windows.  Here is an example:

'~~~~~Form Code~~~~~

Option Explicit

Private Sub Command1_Click()
    Call fEnumWindows 'Look for IE
End Sub


'~~~~~Module Code~~~~~

Option Explicit

Public Const MAX_PATH = 260
Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Public Function EnumFunc(ByVal hwnd As Long, ByVal lpData As Long) As Long
    Dim lResult    As Long
    Dim sWndName   As String
    Dim szClassName As String
'
' This callback function is called by Windows (from the EnumWindows
' API call) for EVERY window that exists.  It populates the aWindowList
' array with a list of windows that we are interested in.
'
    EnumFunc = 1
    szClassName = Space$(MAX_PATH)
    sWndName = Space$(MAX_PATH)

    lResult = GetClassName(hwnd, szClassName, MAX_PATH)
    szClassName = Left$(szClassName, lResult)

    If UCase(szClassName) = "IEFRAME" Then
        lResult = GetWindowText(hwnd, sWndName, MAX_PATH)
        sWndName = Left$(sWndName, lResult)
        'Found an IE window
        'Do something with the window text here
        Debug.Print sWndName
    End If
End Function

Public Function fEnumWindows() As Boolean
    Dim hwnd As Long
'
' The EnumWindows function enumerates all top-level windows
' on the screen by passing the handle of each window, in turn,
' to an application-defined callback function. EnumWindows
' continues until the last top-level window is enumerated or
' the callback function returns FALSE.
'
    Call EnumWindows(AddressOf EnumFunc, hwnd)
End Function
0
razaAuthor Commented:
Call EnumWindows(AddressOf EnumFunc, hwnd)


ERROR INVALID USE OF ADDRESSOF OPRATOR
0
Erick37Commented:
The code marked "Module Code" must be in a module (BAS file). The EnumFunc function must not be in form-level code.

I retried the code and it works fine.
If I move all the code to the form-level code, I get the error you described.
0
razaAuthor Commented:
ok
thank you. it works fine perfect....

how do I get URL at the same time?
0
Erick37Commented:
Getting the URL is a little more involved, and certainly not a 25 pt question.
I am submitting this as the answer to your original question, which you have got working perfectly.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
razaAuthor Commented:
Excellent!! answer.....
0
Erick37Commented:
Getting the URL string from IE's edit window:
http://www.vbcode.com/asp/showsn.asp?theID=1005
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.