Solved

!lose internet-connection when netscape closed!

Posted on 1999-01-23
1
143 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 13 hours left to enroll

623 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