I'm searching a method to close a specific window by the title.
I tried with Process.GetProcessesByName
; but not is working by this case particulary.
I'm searching a method with APIs or similar (Not in C#, I see several code but not work fine in vb.net)
Thanks!
UPDATE
Thanks for the reply. But I'm still have a problem with the solution that you describe me below.
I'm have an only process that's control two windows. Then, if I close (or kill) the Window #2, instantly close the first one (See the image).
By this reason I think in using an API method from the begging.
I'm only want close the second window.
Best Answer
Try using something like this. using
Process.MainWindowTitle
to get the Title Text andProcess.CloseMainWindow
to close down the UI, its a little more graceful than killing the Process.Note: Contains does a case-sensitive search
As far as Win API functions try something like this. Be aware if you close the parent window you will close the children also.