Results 1 to 2 of 2

Thread: getting hWnd's of other programs with api

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Posts
    64

    Post

    I guess what i need is the hWnd of another programs form using api. what i am doing is, making a program that searches for NetZero's banner, and will make it invisible. But, i'm not sure about how i would do this. any help is great. thanks!

    Charlie Jacquez
    16 Year Old Software Developer
    Email: [email protected]
    Web: CJWARES Online
    AIM: CJWARES, SlimmShadee2000, or BIOSzapper
    ICQ: 58493454
    I program: Basic, Visual Basic, HTML, and TI-Calculators
    My System Specs: Click here


  2. #2
    Junior Member
    Join Date
    Feb 2000
    Location
    Petach-Tekvia
    Posts
    25

    Post Try this

    Private Declare Function GetForegroundWindow Lib "user32" () As Long
    Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
    Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd 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
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

    Public Function GetActiveWindowTitle(ByVal ReturnParent As Boolean) As String
    Dim i As Long
    Dim j As Long

    i = GetForegroundWindow


    If ReturnParent Then
    Do While i <> 0
    j = i
    i = GetParent(i)
    Loop

    i = j
    End If

    GetActiveWindowTitle = GetWindowTitle(i)
    End Function
    Public Function GetWindowTitle(ByVal hwnd As Long) As String
    Dim l As Long
    Dim s As String

    l = GetWindowTextLength(hwnd)
    s = Space(l + 1)

    GetWindowText hwnd, s, l + 1

    GetWindowTitle = Left$(s, l)
    End Function


    ' GetActiveWindowTitle Will get you the name of the active window.
    'then u can use :
    windowHandle = FindWindow(vbNullString,GetActiveWindowTitle(False))

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