Is there a way to bring a window to the forefront using Java? Maybe using some operating system library?
It seems to be possible, but then your solution will be very OS specific.
Theoretically, this can be done by placing a call to the win32 API in the following sequence:
Now the problem is "how to call them from java?". Well, all of the above functions are defined in user32.dll , and JNA can access it.
user32.dll
Some examples of user32 API references using JNA:
Use Google to find more.
Hope this helps.
SWT is good for Win32 calls.
import org.eclipse.swt.internal.win32.OS;
@SuppressWarnings ("restriction")
int hwnd = OS.FindWindowW (null, "Titlein" .toCharArray ());
package focus; import com.sun.jna.Native; import com.sun.jna.platform.win32.WinDef.HWND; import com.sun.jna.win32.StdCallLibrary; public class ForegroundWindow { private interface User32 extends StdCallLibrary { final User32 instance = (User32) Native.loadLibrary("user32", User32.class); boolean SetForegroundWindow(HWND handle); HWND FindWindowA(String className, String windowName); HWND GetForegroundWindow(); } private String getWindowName(String winName) { String winText = ""; if (winText.contains(winName)) { return winText; } return null; } public boolean bringWindowToFront(String className, String winName) { HWND hWnd = User32.instance.FindWindowA(className, getWindowName(winName)); if (hWnd == null) { return false; } return User32.instance.SetForegroundWindow(hWnd); } }
Source: https://habr.com/ru/post/1332503/More articles:nmake: can a batch file work as part of the make command block, affect the environment of the nmake.exe process? - nmakeWriting to apache access_log file with php - phpR: Convert data frame (mixed coefficient and numeric) in XTS to R - rCan I use .htpasswd to protect a nonexistent directory (mod_rewrite virtual directory)? - phpRavenDb - Recursive Queries / Indexes, for a Hierarchical Document - c #Redirecting the user to the login page if not authenticated - c #How to display a chart (from the wpf toolkit) behind the scenes? - c #Why are generics in java collections so weird? - javahttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1332507/python-library-for-getting-information-about-svn-repository&usg=ALkJrhjfDltl2I9qbJ6T0rJCNtxazC0jPARails views showing formatting input in double braces, such as {{parameter}} instead of actual values - ruby-on-railsAll Articles