Solved

!lose internet-connection when netscape closed!

Posted on 1999-01-23
1
138 Views
Last Modified: 2010-05-03
How can I check & activcate a netscape window with
the title (where xxx is not known):
xxx - netscape

I wan´t to check if an netscape window  (or several netscape windows) is opened and as soon as they are all
closed the Internet connection should close, too.
PLEASE give an working example!
0
Comment
Question by:qwertzu
1 Comment
 
LVL 3

Accepted Solution

by:
covington earned 200 total points
ID: 1470270
Here's how you can check. You can't check by Window Class because Netscape starts up with a different window class each time. Because of this, you have to check by title.

Usage:

If NetscapeIsRunning Then
    'something
Else
    'close internet connection
End If

Make sure none of your apps have the phrase "Netscape" in the title bar.



Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal aint As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long

Const GW_HWNDNEXT = 2
Const GW_CHILD = 5


Public Function NetscapeIsRunning() As Boolean

    Dim hWndTmp As Long
   
    'get the first child window
    hWndTmp = GetWindow(GetDesktopWindow, GW_CHILD)
   
    'look for netscape in the children
    Do While hWndTmp <> 0
   
        If InStr(WindowTitle(hWndTmp), "Netscape") <> 0 Then
            NetscapeIsRunning = True
            Exit Function
        End If
        'look for a sibling
        hWndTmp = GetWindow(hWndTmp, GW_HWNDNEXT)
               
    Loop
   
End Function

Private Function WindowTitle(hwnd As Long) As String

    Dim lResult As Long
    Dim sTemp As String * 256
   
    lResult = GetWindowText(hwnd, sTemp, 256)
    WindowTitle = Left(sTemp, lResult)
   
End Function
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

910 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

22 Experts available now in Live!

Get 1:1 Help Now