Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can try using JNA. I'll give you some code for Windows (more or less will be for other systems) using Maven: (sorry but I cannot get formatting right)</p> <ol> <li><p>Create Maven project, and add dependencies:<br></p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;net.java.dev.jna&lt;/groupId&gt; &lt;artifactId&gt;jna&lt;/artifactId&gt; &lt;version&gt;3.4.0&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;net.java.dev.jna&lt;/groupId&gt; &lt;artifactId&gt;platform&lt;/artifactId&gt; &lt;version&gt;3.4.0&lt;/version&gt; &lt;/dependency&gt; </code></pre></li> <li><p>Create interface</p> <pre><code>public interface User32 extends StdCallLibrary { User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class, W32APIOptions.DEFAULT_OPTIONS); HWND GetParent(HWND hWnd); HWND FindWindow(String lpClassName, String lpWindowName); HWND SetFocus(HWND hWnd); HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, String lpszClass, String lpszWindow); int GetWindowText(HWND hWnd, char[] lpString, int nMaxCount); } </code></pre></li> <li><p>Create class</p> <pre><code>public final class Win32WindowUtils { private static final int WIN_TITLE_MAX_SIZE = 512; public HWND GetWindowHandle(String strSearch, String strClass) { char[] lpString = new char[WIN_TITLE_MAX_SIZE]; String strTitle; int iFind = -1; HWND hWnd = User32.INSTANCE.FindWindow(strClass, null); while(hWnd != null) { User32.INSTANCE.GetWindowText(hWnd, lpString, WIN_TITLE_MAX_SIZE); strTitle = new String(lpString); strTitle = strTitle.toUpperCase(); iFind = strTitle.indexOf(strSearch); if(iFind != -1) { return hWnd; } hWnd = User32.INSTANCE.FindWindowEx(null, hWnd, strClass, null); } return hWnd; } } </code></pre></li> <li><p>And invoke </p> <pre><code>User32.INSTANCE.SetFocus(Win32WindowUtils.GetWindowHandle(windowTitle.toUpperCase(), null); </code></pre></li> </ol> <p>Of course - <code>windowTitle</code> is your window title (<code>String</code>) that you want to focus.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload