Jon-Leach
asked on
How do I find a windowclass by using the first 9 letters of the caption?
In VB.NET I want to locate a window class by using the first 9 letters of the caption, I am looking at using the FindWindow API is there a better way or easier way of doing this?
FindWindow() requires an EXACT match so you'd have to iterate over EVERY single window and check for your criteria...
ASKER
ok, so then once I find the full caption how can I pull it out and comapare? It is there a Function I can use?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks let me try this.
ASKER
Very helpful was able to modify the code with little effort to do what I wanted in my code.
*FYI, I think Bob (TheLearnedOne) is the original author of the WindowsEnumerator() class I used:
https://www.experts-exchange.com/questions/23357525/get-all-Window-Handles-hWND-associated-with-a-Process.html
He's posted it in many other PAQs and I picked it up and made minor mods to it...
https://www.experts-exchange.com/questions/23357525/get-all-Window-Handles-hWND-associated-with-a-Process.html
He's posted it in many other PAQs and I picked it up and made minor mods to it...
ASKER
I got quick question I moved this section below in it's own function to be called upon by a timer and now I get an error aw note declared? I looked high and low and can;t figure out why it not declaring it.
Dim we As New WindowsEnumerator
Dim DialogWindows As List(Of ApiWindow) = we.GetTopLevelWindows()
For Each aw In DialogWindows
If aw.Text.ToLower.StartsWith("abcdefghi") Then
Label1.text = "Found"
' ... do something in here ...
' ... possibly use "aw.Handle" ? ....
' ... or "aw.ClassName" ? ...
Exit For
End If
Next
You can change:
For Each aw In DialogWindows
To:
For Each aw As ApiWindow In DialogWindows
For Each aw In DialogWindows
To:
For Each aw As ApiWindow In DialogWindows
ASKER
That worked thanks, man was that a duh momnet on my part. Thanks for the help and the other link too.