1

I am developing a screen capturing utility in Java & I want to capture any background window, when I click on that particular window. But I am not getting how to add mouseClicked event to background window. Can somebody please help me?

Baishampayan Ghose
20.8k10 gold badges59 silver badges60 bronze badges
asked Feb 21, 2009 at 7:09
1
  • Is the background window written in Java? Is it running in the same VM? Commented Feb 21, 2009 at 7:20

4 Answers 4

1

I may be way off base but if the other window is not a Java window then it should be outside the Java sandbox. To interact with it requires a native API which is anathema to Java.

answered Feb 21, 2009 at 7:21
Sign up to request clarification or add additional context in comments.

Comments

1

Quite obviously as it is you can't interact with other application windows. It can be any random window in your case I presume. Therefore, your mouselistener approach is not correct.

Rather, try to approach it like fetching pixel information displayed on the screen. There is an awt package java.awt.Robot or something that could be used for your purpose. If you want to implement capturing of active window then see if there are java APIs to interact with O.S. and get information of current active window and it's pixel co-ordinates. The co-ordinates could then be supplied to the rectangle attribute that is used with java.awt.Robot APIs to define screen capture area.

answered Feb 21, 2009 at 9:16

Comments

0

If that window is not part of your application you can't do much with it.

Otherwise you just have to add the mouse listener to that window too.

What's your situation?

answered Feb 21, 2009 at 7:22

Comments

0

java.awt.Robot has a method createScreenCapture(Rectangle screenRect) to capture screenshots. http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Robot.html

however, to get the current active window you would have to use OS specific extensions (mostly via JNI)

answered Feb 21, 2009 at 13:02

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.