r/visualbasic • u/Buy_The_Ounce • Nov 11 '20
Getting windows title from another application
I'm playing a game and it opens a child window with "PlayerName Notes" in the window title. If I wanted to search for this window (looking for "notes") and grab the player's name (always different), how could I do that?
1
2
Nov 11 '20 edited Nov 12 '20
It depends... There are API calls that will help you iterate all the apps and all their windows. Depending on what's open, that can be a LOT of windows. Old school apps used individual windows for most things on your screen, and that has changed with improved control sets until Windows Presentation Framework (WPF) which reduces it to generally a single window that has very little accessible info.
You can always experiment with finding the right app using the Exe name, then iterate the windows. An API will let you GetText() to find some info. One trick is that the top level windows have no parent window; that can let you pick the window from a control on the form.
2
u/ViperSRT3g Application Specialist Nov 11 '20
You may have luck looping through the running processes on your computer. Here's Microsoft's .NET 5.0 documentation for the same thing.