0

Is there any way to get the title and coordinates of the active window on the desktop? Window can belong to any process, not necessarily to the one that I'm developing. I'd like to do it on java, probably with the calls of some native API.

j3raks
  • 23
  • 1
  • 6

1 Answers1

0

Someone correct me if i am wrong but you wont be able to use a native API with java if it isnt part of java already, meaning you wont be able to find a pure Java solution.

You can use JNI(Java Native Interface) to create a 'link' using C/C++ and that would allow you to use native API from Java. EDIT: JNA(Java Native Access) is another possible solution i believe.

You could also use C# or VB.net which i believe that already have support for windows API.

The functions you are looking for might be
GetForegroundWindow to get the window itself.
GetWindowRect to get coordinates.
( note that these links are for C++, C#/VB might have access to those in some way )

For you to use Java you will have to ,as i said, somehow 'link' the native API with java because Java alone can't.


This question about getting window title might have answers that explain Java's limits for this type of things better.
Get current active window's title in Java

Community
  • 1
  • 1
Zentdayn
  • 62
  • 2
  • 9