Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FindWindow with partially known title

Tags:

c#

pinvoke

Example Outlook: its only one process but can have multiple windows (user can double click on the email to open it in its own window)

So, I cannot use Process.GetProcess() to iterate through the processes and compare title.

FindWindow() needs full title; I know the title but Outlook window adds its own in the end i.e. - Message (Rich Text) or - Message (HTML) .. etc.

Can I get all the email windows (handles) for Outlook ? then iterate over those to find my window using GetWindowText() ? Any pointers will be highly appreciated.

like image 726
karephul Avatar asked Jan 12 '12 18:01

karephul


1 Answers

You can use EnumWindow to enumerate through all the windows finding the one you want.

http://www.pinvoke.net/default.aspx/user32.enumwindows

like image 58
Will Avatar answered Oct 05 '22 00:10

Will