0
votes

I have a Java program that launches another Java application via ProcessBuilder. My program also retains a Process object after launching the other application.

ProcessBuilder launcher = new ProcessBuilder(argArray);
Process processHandle = launcher.start();

In my program, I have 'user preferences' where the user can specify the on-screen size and location of the other application that is being started. I need my program to be able to change the size and location of the other application's window in pixels, preferably without utilizing P/Invoke, as this is meant to be a cross-platform application. Does anyone know how to change a Process' window size and location programmatically in Java?

1
AFAIK ,There is no such option. However , if you explain more about what you want to acheive. and what type of application you are launching from your java application, it would be better to understand and explore further options. - user3505725
The worst case scenario would be to use java.util.Robot class to programatically generate mouse and key press(maybe ctrl+space) , maximize and move the window. - user3505725

1 Answers

2
votes

You can't do this with pure Java, but if you write a JNI DLL you can do it via SetWindowPos in Windows.

Check the API: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspx

You can get the HWND of the remote process via a combination of calls to EnumWindows and GetWindowThreadProcessId.