1

I am wondering is it possible somehow to move another window on the screen to different location using Java ?

Example: I would like to move this window to the marked location. example

Welite
  • 161
  • 4
  • 17
  • Probably not. That would be a clear security concern if that were possible. – fge May 04 '16 at 11:41
  • So, given the function [`SetWindowPos`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspx) from the WinAPI and something like [this JNA example](http://stackoverflow.com/questions/6091531/how-to-get-the-x-and-y-of-a-program-window-in-java/6091597#6091597), I would say, generally yes – MadProgrammer May 04 '16 at 11:46
  • [JNA](https://github.com/java-native-access/jna) provides a [`User32#SetWindowPos`](http://java-native-access.github.io/jna/4.2.1/com/sun/jna/platform/win32/User32.html#SetWindowPos-com.sun.jna.platform.win32.WinDef.HWND-com.sun.jna.platform.win32.WinDef.HWND-int-int-int-int-int-) function – MadProgrammer May 04 '16 at 11:50

1 Answers1

0

Interfering with other programs is usually only allowed with superuser access (root). If you do not mind executing your program as root, there are possibilities, but they are certainly not cross-platform, so you would have to write a version for every OS around. I would not use java for such things.

Also, the answer about using the Windows API will not work, since you will not be able to get the window handle of a different process. Just check the documentation:

SetWindowPos Changes the size, position, and Z order of a child, pop-up, or top-level window.

Java APIs will not help you out here.

BT9
  • 87
  • 1
  • 11