• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

get coordinates of all running forms

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody, i'm looking to a way to get all visible forms; can java enumerate all applications running and their forms to get coordinates ?

thanks
Teo
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not without quite some native code. All it has access to are all window objects created by the current application.

You will need the "EnumWindows" call in C or Visual Basic to enumerate over all windows. Inside the enumerating function you can use "IsWindowVisible", "GetWindowText" and "GetWindowRect" to query the visibility, caption and bounds of the windows.

A bit of template code you may be able to use:

You call this as follows:
with xxx being a pointer to some structure you want to pass along to the GetWindowInformation function.

Here's also the code to create a java.awt.Rectangle from a RECT object (ignoring any possible error codes):
 
Matteo Lanzi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rob, thanks a lot for your answer.
some little questions more;

so you mean in java i can use an int pointer to a window?

in java with (*env) i can dereference a pointer?

of course i have to make dll for win mac and linux, so can embed them in the project and still use an applet? I'd like to use an applet because this application have to works with a flex application

thanks again

Teo
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all a warning: the code I posted is native C code, and works with Windows only. Mac and Linux have different ways which unfortunately I don't know, and is also determined to the windowing system used. X11 and Xorg may have different calls for this.

Matteo Lanzi wrote:so you mean in java i can use an int pointer to a window? [/url]


HWND is the same size as an int, so yes you can. Just remember to cast it back to HWND in native code.
However, I don't know the size of window handles in Mac or Linux, so you may have to end up with long instead and discard part of it when converting to HWND.

in java with (*env) i can dereference a pointer?


There are no pointers in Java. As I said at the top of this post, the code I posted is C code. With (*env) you can dereference a pointer in C, but not in Java.

of course i have to make dll for win mac and linux, so can embed them in the project and still use an applet? I'd like to use an applet because this application have to works with a flex application


If you use the same class(es) for Windows, Mac and Linux with just different native implementations, there is no problem. Just call System.loadLibrary and it will translate the library for you to a native file. For instance, searches for mywindows.dll in Windows, and for libmywindows.so in Linux (and probably Mac as well).
 
Matteo Lanzi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your support
 
I do some of my very best work in water. Like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic