I am interacting with a third party application using it's API, and would like to move it to the front of focus (so that it is on top of all other open windows) when a user performs a certain action. While I can move my application up and down in the hierarchy pretty easily, there doesn't appear to be a way to interact with other windows. Is it possible to move another program's window to front with Java?
To make the active window always on top, press Ctrl + Spacebar (or the keyboard shortcut you assigned). Press the keyboard shortcut again to disable “always on top” for the active window. For script options, right-click on the AutoHotkey icon in the system tray.
You can't do it in pure Java code, but you could using JNI. See In Java Swing how do you get a Win32 window handle (hwnd) reference to a window? for how to get a handle to the window. Then you could do something like http://msdn.microsoft.com/en-us/library/ms633545 to move it to the front.
Caveat: This is for windows only
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With