Skip to content

Find a window by partial Caption In VB.NET

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #189251
    Newbie
    Member

    How can we find a windows by partial caption in VB.NET ?
    I read the exemple of Departure to do it in VB6, but i cannot convert it to VB.NET 🙁 need to FindWindow(“” – Voice Room”)

    #189260
    Admin
    Administrator

    have u chek this post I think there is a part of the code that can get the room name just using Group Voice 🙂

    I think

    #189259
    Newbie
    Member

    No

    i dont find where did you see the findwindow Voice Group

    #189258
    AhFox
    Member

    I believed he wants a code that … grab all the chatrooms opened ….

    Such as string “Voice Group”

    For examples:

    If you are having 2 chatrooms opened… then a user selects one.

    Is that right?

    #189257
    Newbie
    Member

    Pm and Rooms have the same winclass

    All i want to do is to find the room window and not the PM one

    #189256
    Departure
    Member

    he wants the FindWindowWild Function converted over to VB.net, This way he will always get the correct room instead of the Pm, sorry i can’nt help you newbie with .net as i dont like to program with it and i dont want to learn it…

    The findwildfunction i made years ago still works a treat even today :O)

    #189255
    AhFox
    Member

    hahahaha … well this is easy …

    STOP using vbNullString

    FindWondow(“My class window”, then you put a string here … instead of vbNullString)

    #189254
    Departure
    Member

    not that easy NVYE, yes you could just change VBnullstring to the window name… But that would miss the whole point of making a program to do it and you would be limited to the one room, and ytou say change FindWondow(“My class window”, then you put a string here … instead of vbNullString) well you first have to find the string and thats where the Findwindowwild function comes into play. like i said it works a treat

    #189253
    AhFox
    Member

    well … I think there is a lot of API out there … allows you to grab … all the windows ….

    Then instr them … Voice Group or IM Chat or something like that I forgot … and it returns only that …

    returns to a list then let a user select it …

    or you can do … Auto Linker …. get the active application title .. and recorded the latest one.

    Maiek sure you instr too … for voice is instr(“Voice Group”) … IM is something I forgot ….

    hope this helps.

    #189252

    try this one:
    ‘ public declaration in your form1
    Private Declare Function GetWindowText Lib “user32” Alias “GetWindowTextA” (ByVal hwnd As Integer, ByVal lpString As String, ByVal cch As Integer) As Integer
    Private Declare Function GetWindowTextLength Lib “user32” Alias “GetWindowTextLengthA” (ByVal hwnd As Integer) As Integer

    Public Delegate Function MyDelegateCallBack(ByVal hwnd As Integer, ByVal lParam As Integer) As Boolean

    Declare Function EnumWindows Lib “user32” (ByVal x As MyDelegateCallBack, ByVal y As Integer) As Integer
    Dim wndtitle As String
    ‘function to evaluate the output of enumwindows
    Public Function EnumOutput(ByVal hwnd As Integer, ByVal lParam As Integer) As Boolean
    Dim length As Integer = GetWindowTextLength(hwnd)
    Dim sb As String = Space(length)
    GetWindowText(hwnd, sb, length + 25)
    If sb.Length < 1 Then
    Return True
    End If
    Dim title As String = sb.ToString()
    If title “” Then
    If title.IndexOf(“Voice Room”) > -1 Then

    wndtitle = title
    MessageBox.Show(title)
    Return False ‘stop find next window
    End If
    End If

    Return True
    End Function
    ‘and call the api function in the button click
    EnumWindows(AddressOf EnumOutput, 0)
    ‘ the result will store in a variable wndtitle

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.