How can I get the window handle by giving the process name or window title in c#.. given the process is in running already
auto processId = FindProcessId(L"blabla.exe"); Show activity on this post. You can use GetModuleName (I think?) to get the name and check against that. Most of the GetModuleName, QueryFullProcessImage name, etc., require a handle and thus won't be of much use.
You can use EnumWindows and GetWindowThreadProcessId() functions as mentioned in this MSDN article.
The MainWindowHandle property is a value that uniquely identifies the window that is associated with the process. A process has a main window associated with it only if the process has a graphical interface. If the associated process does not have a main window, the MainWindowHandle value is zero.
You can use the Process
class.
Process[] processes = Process.GetProcessesByName("someName"); foreach (Process p in processes) { IntPtr windowHandle = p.MainWindowHandle; // do something with windowHandle }
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