Java Code Examples for com.sun.jna.platform.win32.User32#PeekMessage
The following examples show how to use
com.sun.jna.platform.win32.User32#PeekMessage .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventFetcherLogicRunner.java From canon-sdk-java with MIT License | 5 votes |
/** * <p><b>Compatible only with windows!</b></p> */ protected void fetchEventWithUser32() { final User32 lib = User32.INSTANCE; final WinUser.MSG msg = new WinUser.MSG(); final boolean hasMessage = lib.PeekMessage(msg, null, 0, 0, 1); if (hasMessage) { lib.TranslateMessage(msg); lib.DispatchMessage(msg); } }
Example 2
Source File: EventCameraTest.java From canon-sdk-java with MIT License | 5 votes |
@Test @EnabledOnOs(OS.WINDOWS) @Disabled("Only run manually") void cameraConnectedIsSeenWithUser32() throws InterruptedException { // This test demonstrate how to get events from library using User32 but better to use EdsGetEvent of library final User32 lib = User32.INSTANCE; final AtomicBoolean cameraEventCalled = new AtomicBoolean(false); TestShortcutUtil.registerCameraAddedHandler(inContext -> { log.warn("Camera added called {}", inContext); cameraEventCalled.set(true); return new NativeLong(0); }); final WinUser.MSG msg = new WinUser.MSG(); for (int i = 0; i < 100; i++) { Thread.sleep(50); final boolean hasMessage = lib.PeekMessage(msg, null, 0, 0, 1); if (hasMessage) { log.warn("Had message"); lib.TranslateMessage(msg); lib.DispatchMessage(msg); } } Assertions.assertTrue(cameraEventCalled.get()); }