1

I am trying to create a program in Java that is able to get positional information from unrelated windows in Windows. I need the rectangle from all the visible windows, I need to know which ones are minimized and also their Z-order. I read on a lot of questions here, learned a bit from JNA, but I still have some issues. (I gathered most of the information I know from here, even though I couldn't compile the code: Windows: how to get a list of all visible windows?)

  1. The program shows a LOT of windows, even though they are not user-windows. I did not know Windows worked this way, so how can I filter what is a user window from all the other 'junk' windows?

  2. The linked code from @mdma does not compile because Main.RECT must implement an abstract method from jna.Structure (getFieldOrder()). Is this an issue related to different versions of JNA? Am I doing something obviously wrong?

I am struggling to learn JNA in order to be able to create this program, but I never dealt with WinAPI and it is rather confusing. Thank you for your patience.

Edit: This is a short snippet of the code I couldn't compile. I am using the latest JNA (3.5.1).

import com.sun.jna.Structure;

public class Main {
    public static void main(String[] args) {
        public static class RECT extends Structure {
            public int left,top,right,bottom;
        }
    }
}
Community
  • 1
  • 1
Pedro Cimini
  • 175
  • 1
  • 1
  • 7
  • Consider showing your failed code as an [sscce](http://sscce.org) similar to the example posted as well as showing the exact error message. Also are you using the latest JNA library? – Hovercraft Full Of Eels Apr 01 '13 at 00:18
  • 1
    Hello, @HovercraftFullOfEels, I read a lot of your JNA code throughout related answers in SO and I learned a lot with it. I did not paste the related code simply because I could not compile it, and I don't know why, but I edited a short code with only the faulty part. I am a bit against just copying code from other people because I did not write them. Anyhow, I am using JNA 3.5.1, both jars are in the build path and everything seems normal. Thank you! – Pedro Cimini Apr 01 '13 at 00:35
  • What if you don't create your own RECT, but rather use the RECT class that comes with JNA. Have you tried importing it: `import com.sun.jna.platform.win32.WinDef.RECT;`? – Hovercraft Full Of Eels Apr 01 '13 at 01:51

0 Answers0