0

Is it possible to detect a mouse click anywhere on a screen, outside of my application?

I have written an application to do this in C#, but would like to write a version of this in Java so that it can be run on several platforms.

It looks like I can get the co-ordinates of the mouse at any time with java.awt.MouseInfo.getPointerInfo() but I am not sure as to how to listen for a mouse click.

In C# I used GetAsyncKeyState to detect whether the mouse button was clicked, but obviously I cannot use this if I wish to keep this "clean" for use in multiple platforms.

asked Feb 1, 2011 at 23:43
1

1 Answer 1

5

You can do this only with platform specific implementation of the OS API, as you can't detect clicks outside from your program in your program itself.

While you won't get around writing platform specific code, just abstract it as an interface and use different implementations appropiately.

answered Feb 1, 2011 at 23:47
Sign up to request clarification or add additional context in comments.

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.