Find a window by partial Caption In VB.NET

You can talk about VB programming here

Find a window by partial Caption In VB.NET

Postby Newbie » Sat Oct 22, 2005 6:02 pm


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")
User avatar
Newbie
imFiles Junior
imFiles Junior
 
Posts: 95
Joined: Fri Oct 07, 2005 2:51 pm

Postby locohacker » Sun Oct 23, 2005 10:09 am

have u chek this post http://imfiles.com/paltalk/paltalkin ... vt661.html I think there is a part of the code that can get the room name just using Group Voice :)

I think
User avatar
locohacker
Site Admin
Site Admin
 
Posts: 4361
Joined: Fri Dec 31, 2004 6:59 pm

Postby Newbie » Sun Oct 23, 2005 11:38 am

No

i dont find where did you see the findwindow Voice Group
User avatar
Newbie
imFiles Junior
imFiles Junior
 
Posts: 95
Joined: Fri Oct 07, 2005 2:51 pm

Postby NVYE » Sun Oct 23, 2005 2:31 pm

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?
User avatar
NVYE
imFiles Senior
imFiles Senior
 
Posts: 234
Joined: Fri Jun 10, 2005 11:29 pm

Postby Newbie » Sun Oct 23, 2005 3:41 pm

Pm and Rooms have the same winclass

All i want to do is to find the room window and not the PM one
User avatar
Newbie
imFiles Junior
imFiles Junior
 
Posts: 95
Joined: Fri Oct 07, 2005 2:51 pm

Postby Departure » Sun Oct 23, 2005 9:55 pm

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)
User avatar
Departure
Global Moderator
Global Moderator
 
Posts: 996
Joined: Thu Mar 17, 2005 11:26 am
Location: Australia

Postby NVYE » Mon Oct 24, 2005 7:26 am

hahahaha ... well this is easy ...

STOP using vbNullString

FindWondow("My class window", then you put a string here ... instead of vbNullString)
User avatar
NVYE
imFiles Senior
imFiles Senior
 
Posts: 234
Joined: Fri Jun 10, 2005 11:29 pm

Postby Departure » Mon Oct 24, 2005 7:54 am

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
User avatar
Departure
Global Moderator
Global Moderator
 
Posts: 996
Joined: Thu Mar 17, 2005 11:26 am
Location: Australia

Postby NVYE » Mon Oct 24, 2005 9:28 am

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.
User avatar
NVYE
imFiles Senior
imFiles Senior
 
Posts: 234
Joined: Fri Jun 10, 2005 11:29 pm

just calll api function EnumWindows

Postby BattleStar-Galactica » Fri Feb 17, 2006 12:24 am

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
User avatar
BattleStar-Galactica
imFiles Master
imFiles Master
 
Posts: 565
Joined: Tue Sep 20, 2005 12:19 am
Location: safest place to hide


Return to Visual Basic Programming

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 0 guests

cron