Getting window handle without matching window caption text 
Author Message
 Getting window handle without matching window caption text

I am having trouble getting the window handle of a running application.  I
do not want to match based on window caption text.

I have tried the following:

1) FindWindow - When I specify only the class name I get nothing in return.
Example: FindWindow("WindowsApplication1.Form1", null) returns IntPtr.Zero.

2) Process.GetProcessesByName - This gives me the process but I can't seem
to get the window handle from there.  The MainWindowHandle property returns
IntPtr.Zero if the window is hidden or set to not visible.

3) EnumWindows - Cannot find a way to get the window handle without matching
on caption text.

Any ideas???

Greg



Mon, 08 Nov 2004 04:15:31 GMT  
 Getting window handle without matching window caption text
Wrong class name. The class name for the window will be something like:
"WindowsForms10.Window.8.app7e" even though the actual class name for your
form may be something like "WindowsApplication1.Form1" - but the class name
will be different for different versions of your app so don't count on it to
always be the same - I think it is assigned by the runtime since it is
"hosting" the app like in a virtual machine.

Use a windows spy app to see what the class name is to pass to FindWindow.

(I use Spy & Capture - freeware by Krichmar Kobi - you can get it here:
http://my.magicpage.co.il/Comp/kobik/download/spy.zip )
--

-Ryan


I am having trouble getting the window handle of a running application.  I
do not want to match based on window caption text.

I have tried the following:

1) FindWindow - When I specify only the class name I get nothing in return.
Example: FindWindow("WindowsApplication1.Form1", null) returns IntPtr.Zero.

2) Process.GetProcessesByName - This gives me the process but I can't seem
to get the window handle from there.  The MainWindowHandle property returns
IntPtr.Zero if the window is hidden or set to not visible.

3) EnumWindows - Cannot find a way to get the window handle without matching
on caption text.

Any ideas???

Greg



Mon, 08 Nov 2004 05:36:33 GMT  
 Getting window handle without matching window caption text
I still have not found a solution.  I did find this article but have not yet
deciphered it:

http://www.pgh.net/~newcomer/nomultiples.htm

Greg



Wed, 10 Nov 2004 05:47:43 GMT  
 Getting window handle without matching window caption text
What are you trying to accomplish? If you are trying to prevent multiple
instances of your app (which you did not mention in your original post) then
you can find a good example in C# here:

http://www.syncfusion.com/faq/winforms/search/550.asp

- or here -

http://www.c-sharpcorner.com/FAQ/Create1InstanceAppSC.asp
--

-Ryan


I still have not found a solution.  I did find this article but have not yet
deciphered it:

http://www.pgh.net/~newcomer/nomultiples.htm

Greg



Sat, 13 Nov 2004 12:14:01 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Getting a handle to a child window / Resizing a child window

2. Getting a handle to a window from the window instance

3. Getting a pointer to a window from the window handle

4. Getting a handle to a child window / Resizing a child window

5. Window without caption bar

6. Creating A Window Without A Caption Bar.....

7. Moving windows without visible caption

8. Moving Windows Without Captions

9. Making a main(frame)window without a border and caption (just white)

10. problem:Getting window's text from other process-difference between text and title

11. Window caption text??

12. Windows Caption Text??

 

 
Powered by phpBB® Forum Software