3 messages in net.java.dev.jna.usersRe: Re: [jna-users] info about other ...
FromSent OnAttachments
Guan EglesioJan 20, 2009 12:17 pm 
Stefan EndrullisJan 21, 2009 1:25 am 
rzoJan 21, 2009 2:57 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Re: [jna-users] info about other windowsActions...
From:rzo (rz@gmx.de)
Date:Jan 21, 2009 2:57:51 am
List:net.java.dev.jna.users

Hello,

for windows, maybe this example could help:

public interface MyUser32 extends com.sun.jna.examples.win32.Kernel32 { // Method declarations, constant and structure definitions go here

/** The INSTANCE. */ MyUser32 INSTANCE = (MyUser32) Native.loadLibrary("User32", MyUser32.class);

public interface WNDENUMPROC extends StdCallCallback { /** Return whether to continue enumeration. */ boolean callback(Pointer hWnd, int data); }

boolean EnumWindows(WNDENUMPROC lpEnumFunc, int data); } // define callback to print pid of window MyUser32.WNDENUMPROC callback= new MyUser32.WNDENUMPROC() { public boolean callback(Pointer wnd, int lParam) { // print the pid of the window IntByReference dwID = new IntByReference(); MyUser32.INSTANCE.GetWindowThreadProcessId(wnd, dwID); System.out.println(dwID.getValue()); } // continue with next window return true; } }; // show pid of all windows MyUser32.INSTANCE.EnumWindows(callback, 0);

- Ron http://yajsw.sourceforge.net/

Stefan Endrullis wrote:

Hi Guan,

Guan Eglesio schrieb:

Im writing a java app that needs some OS specific info (winxp);

- information about all the windows that are currently open (firefox/itunes/notepas/etc)

for instance there: size/location/state etc.

If you would ask for the same under Linux, I could suggest you the "x11" project in the "contrib" section. There you have all you need to get easily to this information.

Can i do this with JNA?

But it should be also possible under Windows. You just have to write the JNA mappings for necessary C libraries.

BTW there's already a class in the examples section which allows you to set window transparency and shape. Maybe this file (especially the inner class W32WindowUtils) could be a good starting point. The location of the file is: trunk/jnalib/src/com/sun/jna/examples/WindowUtils.java