0

I need to know if a Java client is open with my java program that runs on the background. Java will not allow me to view other windows that are not running on the same virtual machine. I think that if I make a java program, that open the java client I want to keep track of it would work, but I did not manage to do this (did try a lot). My other option is to use java robot and take a screenshot of the screen and the iterate the find pixel information until I match the pixel of the client I am looking for.


The client is a program that I should not manipulate directly, and I did not write it. So its a third party's.For the simplicity, lets say the client has an area that switches color between red and green, red means problems and green means its okay.
The program running on the background uses the client as a trigger mechanism, meaning if the client shows RED. I should not do something, and if it shows green I should (so I only need to find if the color in certain location of the client is Red or not.

Comparing:

Robot:
-Easy to implement?
- Will give the user more confident that I am not stealing his information.

Starting both programs in the same VM:
-More profesional
-I can keep track of the cleint without iterating through all the window's pixel
-The window will not be "hiden" by other programs
-When the window moves I dont have to re-iterate to find it again.

Bad:
Robot:
- Iterations may take a while
-Have to iterate every time the javaclient is move.
Starting both programs in the same VM:
-Program will requiere more configuration, and installing other "things" (I want something easy and fast to use)

Feel free to comment on efficiency, other options or to give me bits & pieces for these two options.

Thank you (I decided to keep trying with java instead of C/C++ because possible users may run other OS than windows)

Juan
  • 521
  • 1
  • 11
  • 28
  • It's not clear what you want to do. What is the Java client supposed to do? What is the background app supposed to do? How are they related together? – JB Nizet Dec 02 '11 at 11:33
  • @JBNizet Okay, I added a little more hope it helps. – Juan Dec 02 '11 at 11:51

1 Answers1

1

Instead of taking a screenshot, why not getting a list of processes or windows? You can use "EnumWindows" or "EnumProcesses" in Windows with JNI or JNA. For Linux, "ps" retrieves a list of processes. Alternately, you can use a client-server model and let your client "ping" to your server.

belgther
  • 2,544
  • 17
  • 15