The title is partially static with an variable suffix. For example "Window Title {- user_id}".
How can I get the handle without knowing the exact title?
Look through all the Processes and check the MainWindowTitle. (You can use regexps, or StartsWith
, etc)
foreach(Process proc in Process.GetProcesses())
{
if(proc.MainWindowTitle.StartsWith("Some String"))
{
IntPtr handle = proc.MainWindowHandle;
// ...
}
}
This CodeProject article describes how to enumerate Top level windows (Based on Win32 API EnumWindows). You can easily modify it to filter on a partial window title: Modify EnumWindowsCallBack.
HTH.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With