Search in sources :

Example 1 with DesktopWindow

use of com.sun.jna.platform.DesktopWindow in project jna by java-native-access.

the class User32Test method testSendMessage.

@Test
public void testSendMessage() {
    DesktopWindow explorerProc = getWindowByProcessPath("explorer.exe");
    assertNotNull(explorerProc);
    LRESULT result = User32.INSTANCE.SendMessage(explorerProc.getHWND(), WinUser.WM_USER, new WPARAM(124), new LPARAM(12345));
    assertNotEquals(0, result);
}
Also used : LRESULT(com.sun.jna.platform.win32.WinDef.LRESULT) LPARAM(com.sun.jna.platform.win32.WinDef.LPARAM) WPARAM(com.sun.jna.platform.win32.WinDef.WPARAM) DesktopWindow(com.sun.jna.platform.DesktopWindow) Test(org.junit.Test)

Example 2 with DesktopWindow

use of com.sun.jna.platform.DesktopWindow in project jna by java-native-access.

the class User32Test method testSendMessageTimeout.

@Test
public void testSendMessageTimeout() {
    DesktopWindow explorerProc = getWindowByProcessPath("explorer.exe");
    assertNotNull(explorerProc);
    final DWORDByReference hIconNumber = new DWORDByReference();
    LRESULT result = User32.INSTANCE.SendMessageTimeout(explorerProc.getHWND(), WinUser.WM_GETICON, new WPARAM(WinUser.ICON_BIG), new LPARAM(0), WinUser.SMTO_ABORTIFHUNG, 500, hIconNumber);
    assertNotEquals(0, result);
}
Also used : LRESULT(com.sun.jna.platform.win32.WinDef.LRESULT) DWORDByReference(com.sun.jna.platform.win32.WinDef.DWORDByReference) LPARAM(com.sun.jna.platform.win32.WinDef.LPARAM) WPARAM(com.sun.jna.platform.win32.WinDef.WPARAM) DesktopWindow(com.sun.jna.platform.DesktopWindow) Test(org.junit.Test)

Example 3 with DesktopWindow

use of com.sun.jna.platform.DesktopWindow in project jna by java-native-access.

the class User32Test method testGetClassLongPtr.

@Test
public void testGetClassLongPtr() {
    if (System.getProperty("os.arch", "unknown").equalsIgnoreCase("amd64")) {
        DesktopWindow explorerProc = getWindowByProcessPath("explorer.exe");
        assertNotNull("Could not find explorer.exe process", explorerProc);
        ULONG_PTR result = User32.INSTANCE.GetClassLongPtr(explorerProc.getHWND(), WinUser.GCLP_HMODULE);
        assertNotEquals(0, result.intValue());
    } else {
        System.err.println("GetClassLongPtr only supported on x64");
    }
}
Also used : ULONG_PTR(com.sun.jna.platform.win32.BaseTSD.ULONG_PTR) DesktopWindow(com.sun.jna.platform.DesktopWindow) Test(org.junit.Test)

Example 4 with DesktopWindow

use of com.sun.jna.platform.DesktopWindow in project jna by java-native-access.

the class WindowUtilsTest method testGetAllWindows.

public void testGetAllWindows() {
    final List<DesktopWindow> allWindows = WindowUtils.getAllWindows(false);
    final List<DesktopWindow> allVisibleWindows = WindowUtils.getAllWindows(true);
    assertTrue("Found no windows", allWindows.size() > 0);
    assertTrue("Found no visible windows", allVisibleWindows.size() > 0);
    assertTrue("Expected more non-visible windows than visible windows", allWindows.size() > allVisibleWindows.size());
    DesktopWindow explorerProc = null;
    for (final DesktopWindow dw : allWindows) {
        if (dw.getFilePath().toLowerCase().endsWith("explorer.exe")) {
            explorerProc = dw;
            break;
        }
    }
    assertNotNull("explorer.exe was not found among all windows", explorerProc);
    explorerProc = null;
    for (final DesktopWindow dw : allVisibleWindows) {
        if (dw.getFilePath().toLowerCase().endsWith("explorer.exe")) {
            explorerProc = dw;
            break;
        }
    }
    assertNotNull("explorer.exe was not found among visible windows", explorerProc);
}
Also used : DesktopWindow(com.sun.jna.platform.DesktopWindow)

Aggregations

DesktopWindow (com.sun.jna.platform.DesktopWindow)4 Test (org.junit.Test)3 LPARAM (com.sun.jna.platform.win32.WinDef.LPARAM)2 LRESULT (com.sun.jna.platform.win32.WinDef.LRESULT)2 WPARAM (com.sun.jna.platform.win32.WinDef.WPARAM)2 ULONG_PTR (com.sun.jna.platform.win32.BaseTSD.ULONG_PTR)1 DWORDByReference (com.sun.jna.platform.win32.WinDef.DWORDByReference)1