Solved

!lose internet-connection when netscape closed!

Posted on 1999-01-23
1
137 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
Comment Utility
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

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.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
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…

772 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