Results 1 to 3 of 3

Thread: Backgound Monitor Searching for titlebar name

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715

    Exclamation

    I am making a background monitoring program that will write something to a .dat file if someone tries to open the file, like for example MyProgram - notepad then my second (monitor) program will write something to a file, and next time someone runs my program a message will appear, so how do I get my monitor program to scan the Title bars of all open programs for the words "MyProgram", and if it says something else beside "MyProgram" it iwll write something to a file. So how do I scane the title bars?
    NXSupport - Your one-stop source for computer help

  2. #2
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    You could try:

    AppActivate "MyProgram"

    If it generates an error then the window's not found.

  3. #3
    Guest
    You could use the EnumWindows API.

    Put the following in a Module:
    Code:
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
    Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
    
    Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
        Dim Length As Long
        Dim Buffer As String
        Dim Temp As String
        Static iCount As Integer
        
        iCount = iCount + 1
        Length = GetWindowTextLength(hwnd) + 1
        
        If Length > 1 Then
          Buffer = Space(Length)
          GetWindowText hwnd, Buffer, Length
          Temp = Left(Buffer, Length - 1)
          If Temp = "Tips" Then MsgBox ("Window Found")
        End If
        
        EnumWindowsProc = 1
    End Function
    Put a CommandButton on the Form with the following code in it.
    Code:
    EnumWindows AddressOf EnumWindowsProc, 0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width