Click here to Skip to main content
15,908,111 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

I am having an issue i haven't been able to resolve.

Can someone please be nice enough and explain me where I am going wrong.

Here is the situation:

I am evoking an application, which is Java based. How can I check that that window has been created?

I am sure HWND is not going to solve my problem. Since I do get the HWND as soon as I evoke it.

Sometimes it takes a 1 to 5 minutes for the window to come up. It's a Java app.

Is there a way to confirm if the window has been created?


///////////////////////////////////////////////
I am sorry, I should have mentioned this is an external app.
I am starting up the target application using "ShellExecute".
I don't have the code for the target application.
Once I execute that I am looking for the HWND of the target window.
///////////////////////////////////////////////
Posted
Updated 10-Dec-14 1:04am
v2
Comments
Sergey Alexandrovich Kryukov 10-Dec-14 1:24am    
"Sometimes it takes a 1 to 5 minutes for the window to come up." sounds totally crazy. Wrong application, to my taste; you are doing something wrong, and that is the root of the problem.
The problem you try to formulate is not clear. You need to tell us what's on input. If you have HWND, you can always check up if this is a valid window. If you don't have it, what do you know?
—SA
Richard MacCutchan 10-Dec-14 4:57am    
Look at your stratup code to see what you are doing that takes all the time. Most Java apps will start in a few seconds at most.
FISH786 10-Dec-14 7:03am    
I am sorry, I should have mentioned this is an external app.
I am starting up the target application using "ShellExecute".
I don't have the code for the target application.
Once I execute that I am looking for the HWND of the target window.
Richard MacCutchan 10-Dec-14 7:10am    
Java apps have their own way of doing things, it may not be possible.

1 solution

To be honest, any app that takes more than a couple of seconds (ten at the maximum) to create it's window has severe problems and wouldn't survive on my computer as a matter of course: if it doesn't create a window, then the user doesn't know it is running, and is likely to double click it again, and again, and again...

But if you really, really have to use it, then your only solution is going to be to use the EnumWindows function[^] to get the existing windows list repeatedly until the one you want appears in the list: you can probably ID it from teh window title text, depending on what the app does, or possibly compare it to the handle you already have?
 
Share this answer
 
Comments
FISH786 10-Dec-14 7:35am    
TRUE!!! I totally agree with you. However I was trying to avoid using the EnumWindows Function.
But looks like thats the only option to use.
Thank you all.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900