Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting if window containing a string is open

Status
Not open for further replies.

jmikow

Programmer
Mar 27, 2003
114
US
I have learned how to use FindWindow to detect if a window is open, but I need to be able to detect if a window is open that contains a string I pass in.

I need to know if a specific site is open in Internet Explorer and I will know what the title will be but I do not want to have to search for the whole string.

For Example, I want to get the handle for an IE window whose title contains "Example Title". The whole title may be "This is an Example Title - Microsoft Internet Explorer" but I only want to pass it a partial title.

Is this possible? If so I could use some guidance on how to get the handle for the window I'm looking for. I know there will only be 1 window which contains the partial title I am looking for.

Thanks in advance.
 
GetWindowText
GetWindowTextLength

you will need these when you find the window, check for their usage, and when you have the title you can search for partials using InStr() function, check msdn.microsoft.com for info on this function. everything else is pretty self-explanatory
 
Thanks for the starting info.

I will look into those and post more if I have any questions.

Thanks!
 
You should consider the FindWindowPartial function posted in thread711-710383, 'Find Handle - Class/Window Name Changes'.

This function is an enhanced version of FindWindow function. It works just like FindWindow function but allows you to pass wildcards in its arguments.

Thus you can find the window of your interest using:

[tt]hWndIE = FindWindowPartial("*Example Title*", "*")[/tt]
 
Thanks.

I'll look into that. I think I found something similar on another discussion group but I'll evaluate both of them and see how they work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top