c# - FindWindow doesn't return IntPtr.Zero, although the window is already closed -


I am trying to control a Java application from my C # program. Prior to starting program input data, it checks whether any confidential data input window is there, and tries to close them.

This is the code to check that a window exists:

  public static bool windowexists (string window name) {IntPtr hWnd = FindWindow (faucet, windowname); Return (hWnd! = IntPtr.Zero); }  

So far, I just used this method in a while (Alt + F4 was sending in the window), as long as no open input window was left.

The Java application received updates a while ago, and this method does not work anymore. For some reason, WindowExists return true, even after the data input window is closed. It only occurs when the input window is present at least once.

I also tried to add the thread. In the sleep () loop, to ensure that this is not due to some latency in the Java app, but it was not working

Sometimes calling only the windowing crashes the input window

There is no problem with the code, because it worked before, and it still works with other programs, so it should be a problem with updates in the Java program.

Is there any window to check any option / more reliable way? Changing to "Alt + F4" to switch the "window event" may also be worth a try, but I do not know how to send this event to another window in another program.

I am a newbie, so please answer it simple.

Thanks in advance.

I will use the window to see the handle of the Java app, and see if you can understand What else is going on - I believe that there should be a way to say that it is closed.

I think the process list is out of the question. ..


Comments