简体   繁体   中英

Selecting an X window

Is there any way to select an OS window in Java under Xorg?

Essentially I'd like to replicate the functionality of a command like xwininfo, but I'd like to avoid executing it as a child process if possible. As for the actual information needed, I'm looking for the position and size (x, y, width, height) of a window selected by the user, preferably (as with xwininfo) via the mouse, but searching by name would be acceptable as well.

As far as I know this functionality doesn't exist in the standard JDK, but a premade library or some reasonably straightforward JNA code would be perfect. Compatibility is only needed with recent versions of Linux / Xorg.

Thanks for any help!

I do not think this is possible without JNI/JNA coding. But there are libraries that already did this. Take a look on SWT. It probably can do what you need. Take a look on this thread: Does Java allow you to use native UI widgets on Mac OS X? It may be helpful.

Take a look on xdotool too. I have never tried it but it seems exactly what you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM