Java JNA focus a specific Window
<p>I am trying to give my application the power to focus another Window (Notepad in this case)</p>

<p>My Class is looking like this</p>

<pre><code> public static class Win32WindowUtils {

  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);
    }

    private static final int WIN_TITLE_MAX_SIZE = 512;

    public static 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>

<p>And I am calling it by using:</p>

<pre><code>User32.INSTANCE.SetFocus(Win32WindowUtils.GetWindowHandle(windowTitle, null));
</code></pre>

<p>Note: </p>

<pre><code>public String windowTitle = "Unbennant - Editor";
</code></pre>

<p>Sadly nothing is happening and I dont know why</p>