当前位置: 首页>>代码示例>>Java>>正文


Java WinUser类代码示例

本文整理汇总了Java中com.sun.jna.platform.win32.WinUser的典型用法代码示例。如果您正苦于以下问题:Java WinUser类的具体用法?Java WinUser怎么用?Java WinUser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WinUser类属于com.sun.jna.platform.win32包,在下文中一共展示了WinUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: callback

import com.sun.jna.platform.win32.WinUser; //导入依赖的package包/类
@Override
public LRESULT callback(HWND hwnd, int uMsg, WPARAM wParam, LPARAM lParam) {
    Logger.getLogger(SSHAgent.class.getName()).log(Level.FINE, "Windows requests operation: {0}", uMsg);

    switch (uMsg) {
        case MY_WM_COPYDATA: {
            return processMessage(hwnd, wParam, lParam);
        }
        case WinUser.WM_CREATE: {
            return new LRESULT(0);
        }
        case WinUser.WM_DESTROY: {
            libU.PostQuitMessage(0);
            return new LRESULT(0);
        }
        default:
            return libU.DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
}
 
开发者ID:martin-lizner,项目名称:trezor-ssh-agent,代码行数:20,代码来源:SSHAgent.java

示例2: main

import com.sun.jna.platform.win32.WinUser; //导入依赖的package包/类
public static void main(String[] args) {
    final User32 user32 = User32.INSTANCE;
    user32.EnumWindows(new WinUser.WNDENUMPROC() {
        int count = 0;
        @Override
        public boolean callback(WinDef.HWND hwnd, Pointer pointer) {
            byte[] windowText = new byte[512];
            byte[] className = new byte[512];
            user32.GetWindowTextA(hwnd, windowText, 512);
            user32.GetClassNameA(hwnd, className, 512);
            String title = Native.toString(windowText);
            String classN = Native.toString(className);

            // get rid of this if block if you want all windows regardless of whether
            // or not they have text
            if (title.isEmpty()) {
                return true;
            }

            System.out.println("Title: " + title + " Class name: " + classN);
            return true;
        }
    },null);
}
 
开发者ID:Exslims,项目名称:MercuryTrade,代码行数:25,代码来源:Test.java

示例3: pressKeys

import com.sun.jna.platform.win32.WinUser; //导入依赖的package包/类
public void pressKeys(final List<KeyboardKey> keys) {
    if (keys.isEmpty()) {
        return;
    }

    final WinUser.INPUT input = new WinUser.INPUT();
    final WinUser.INPUT[] inputs = (WinUser.INPUT[]) input.toArray(keys.size() * 2);

    final ListIterator<KeyboardKey> iterator = keys.listIterator();
    int index = 0;
    while (iterator.hasNext()) {
        setKeyDown(inputs[index], iterator.next());
        index++;
    }
    while (iterator.hasPrevious()) {
        setKeyUp(inputs[index], iterator.previous());
        index++;
    }

    user32.SendInput(new WinDef.DWORD(inputs.length), inputs, inputs[0].size());
}
 
开发者ID:msiedlarek,项目名称:winthing,代码行数:22,代码来源:KeyboardService.java

示例4: EnumerateWin32ChildWindows

import com.sun.jna.platform.win32.WinUser; //导入依赖的package包/类
public static Map<String, WindowInfo> EnumerateWin32ChildWindows(HWND parentHwnd)
{
	final Map<String, WindowInfo> infoList = new LinkedHashMap<String, WindowInfo>();
	
    class ChildWindowCallback implements WinUser.WNDENUMPROC {
		@Override
		public boolean callback(HWND hWnd, Pointer lParam) {
			WindowInfo wi = new WindowInfo(hWnd, true);
			infoList.put(wi.hwndStr, wi);
			return true;
		}
    }
    
	Api.User32Ex.instance.EnumChildWindows(parentHwnd, new ChildWindowCallback(), new Pointer(0));
    
	return infoList;
}
 
开发者ID:Synthuse,项目名称:synthuse-src,代码行数:18,代码来源:WindowsEnumeratedXml.java

示例5: FindMainWindowFromPid

import com.sun.jna.platform.win32.WinUser; //导入依赖的package包/类
public static HWND FindMainWindowFromPid(final long targetProcessId) {
	
	final List<HWND> resultList = new ArrayList<HWND>();
    class ParentWindowCallback implements WinUser.WNDENUMPROC {
		@Override
		public boolean callback(HWND hWnd, Pointer lParam) {
			PointerByReference pointer = new PointerByReference();
			User32Ex.instance.GetWindowThreadProcessId(hWnd, pointer);
			long pid = pointer.getPointer().getInt(0);
			if (pid == targetProcessId)
				if (resultList.isEmpty())
					resultList.add(hWnd);
			return true;
		}
    }
    
    Api.User32Ex.instance.EnumWindows(new ParentWindowCallback(), 0);
    if (!resultList.isEmpty())
    	return resultList.get(0);
    return null;
}
 
开发者ID:Synthuse,项目名称:synthuse-src,代码行数:22,代码来源:Api.java

示例6: enumerateParentWindowsTest

import com.sun.jna.platform.win32.WinUser; //导入依赖的package包/类
@Test
public void enumerateParentWindowsTest() {
	final Map<String, WindowInfo> infoList = new LinkedHashMap<String, WindowInfo>();

    class ParentWindowCallback implements WinUser.WNDENUMPROC {
		@Override
		public boolean callback(HWND hWnd, Pointer lParam) {
			output("Getting window info " + Api.GetHandleAsString(hWnd));
			//WindowInfo wi = new WindowInfo(hWnd, false);
			infoList.put(getWindow32Information(hWnd, false), null);
			//Api.User32.instance.EnumChildWindows(hWnd, new ChildWindowCallback(), new Pointer(0));
			return true;
		}
    }	    
    Api.User32Ex.instance.EnumWindows(new ParentWindowCallback(), 0);
    output("enumerateParentWindowsTest size: " + infoList.size());
    assertTrue(infoList.size() > 0);
}
 
开发者ID:Synthuse,项目名称:synthuse-src,代码行数:19,代码来源:WinApiTest.java

示例7: main

import com.sun.jna.platform.win32.WinUser; //导入依赖的package包/类
/**
 * @param args (ignored)
 */
public static void main(String[] args)
{
	System.out.println("Installed Physical Monitors: " + User32.INSTANCE.GetSystemMetrics(WinUser.SM_CMONITORS));
	
	User32.INSTANCE.EnumDisplayMonitors(null, null, new MONITORENUMPROC() {

		@Override
		public int apply(HMONITOR hMonitor, HDC hdc, RECT rect, LPARAM lparam)
		{
			enumerate(hMonitor);

			return 1;
		}
		
	}, new LPARAM(0));
}
 
开发者ID:msteiger,项目名称:MonitorBrightness,代码行数:20,代码来源:MonitorInfoDemo.java

示例8: createWindow

import com.sun.jna.platform.win32.WinUser; //导入依赖的package包/类
private static void createWindow(final File f) {
	SwingUtilities.invokeLater(() -> {
		if (!f.isDirectory()) // if the file was changed or deleted before this could execute, exit
			return;
		final BDWindow w = new BDWindow(f);
		windows.add(w);
		w.pack();
		w.setVisible(true);
		
		threadPool.execute(() -> {
			// sets whether the windows blur the background behind them
			Settings.INSTANCE.blurBackground.addListener(enabled -> {
				ch.njol.betterdesktop.win32.User32.enableBlur(w, enabled);
			});
			
			// disables the windows from being hidden when "peeking" the desktop
			Settings.INSTANCE.excludeFromPeek.addListener(enabled -> {
				Dwmapi.setExcludedFromPeek(w, enabled);
			});
			
			// prevents "show desktop" button from hiding the windows
			if (Settings.INSTANCE.showOnDesktop.get()) {
				final HWND progman = User32.INSTANCE.FindWindow("Progman", "Program Manager");
				User32.INSTANCE.SetWindowLongPtr(new HWND(Native.getComponentPointer(w)), WinUser.GWL_HWNDPARENT, progman.getPointer());
				// the following is required so that this setting actually does something - no idea why though
				try {
					Thread.sleep(100);
				} catch (final InterruptedException e1) {}
				w.setAlwaysOnTop(true);
				w.setAlwaysOnTop(false);
			}
		});
	});
}
 
开发者ID:Njol,项目名称:Motunautr,代码行数:35,代码来源:Main.java

示例9: quitProcess

import com.sun.jna.platform.win32.WinUser; //导入依赖的package包/类
/**
 * Quits the given process.
 *
 * @param handle The handle to quit.
 */
public static void quitProcess(final WinDef.HWND handle) {
    ensureWinApiInstances();
    
    user32.PostMessage(handle,
            WinUser.WM_QUIT,
            null,
            null);
}
 
开发者ID:mmarquee,项目名称:ui-automation,代码行数:14,代码来源:Utils.java

示例10: closeWindow

import com.sun.jna.platform.win32.WinUser; //导入依赖的package包/类
/**
 * Closes the given window.
 *
 * @param handle The handle of the window to close.
 */
public static void closeWindow(final WinDef.HWND handle) {
    ensureWinApiInstances();
    
    user32.PostMessage(handle,
            WinUser.WM_CLOSE,
            null,
            null);
}
 
开发者ID:mmarquee,项目名称:ui-automation,代码行数:14,代码来源:Utils.java

示例11: setTransparent

import com.sun.jna.platform.win32.WinUser; //导入依赖的package包/类
private void setTransparent(Component w) {
    this.componentHwnd = getHWnd(w);
    this.settingWl = User32.INSTANCE.GetWindowLong(componentHwnd, WinUser.GWL_EXSTYLE);
    int transparentWl = User32.INSTANCE.GetWindowLong(componentHwnd, WinUser.GWL_EXSTYLE) |
            WinUser.WS_EX_LAYERED |
            WinUser.WS_EX_TRANSPARENT;
    User32.INSTANCE.SetWindowLong(componentHwnd, WinUser.GWL_EXSTYLE, transparentWl);
}
 
开发者ID:Exslims,项目名称:MercuryTrade,代码行数:9,代码来源:AbstractAdrFrame.java

示例12: setTransparent

import com.sun.jna.platform.win32.WinUser; //导入依赖的package包/类
private static void setTransparent(Component w) {
        WinDef.HWND hwnd = getHWnd(w);
        int wl = User32.INSTANCE.GetWindowLong(hwnd, WinUser.GWL_EXSTYLE);
//        wl = wl | WinUser.WS_EX_LAYERED | WinUser.WS_EX_TRANSPARENT;
        wl = wl | WinUser.WS_EX_LAYERED | WinUser.WS_EX_TRANSPARENT;
        User32.INSTANCE.SetWindowLong(hwnd, WinUser.GWL_EXSTYLE, wl);
    }
 
开发者ID:Exslims,项目名称:MercuryTrade,代码行数:8,代码来源:TestOpaque.java

示例13: setMouseHook

import com.sun.jna.platform.win32.WinUser; //导入依赖的package包/类
/**
 * Start watching...
 */
public void setMouseHook() {
    thrd = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                if (!isHooked) {
                    hhk = USER32INST.SetWindowsHookEx(14, mouseHook, KERNEL32INST.GetModuleHandle(null), 0);
                    isHooked = true;
                    WinUser.MSG msg = new WinUser.MSG();
                    while ((USER32INST.GetMessage(msg, null, 0, 0)) != 0) {
                        USER32INST.TranslateMessage(msg);
                        USER32INST.DispatchMessage(msg);
                        //System.out.print(isHooked);
                        if (!isHooked) {
                            break;
                        }
                    }
                } else {
                }
            } catch (Exception e) {
                System.err.println(e.getMessage());
                System.err.println("Caught exception in MouseHook!");
            }
        }
    }, "Named thread");
    threadFinish = false;
    thrd.start();

}
 
开发者ID:martin-lizner,项目名称:trezor-ssh-agent,代码行数:33,代码来源:JNIMouseHook.java

示例14: setDisplaySleep

import com.sun.jna.platform.win32.WinUser; //导入依赖的package包/类
public void setDisplaySleep(final boolean sleep) {
    user32.DefWindowProc(
        getForegroundWindow().get(),
        WinUser.WM_SYSCOMMAND,
        new WinDef.WPARAM(SC_MONITORPOWER),
        new WinDef.LPARAM(sleep ? 2 : -1)
    );
}
 
开发者ID:msiedlarek,项目名称:winthing,代码行数:9,代码来源:DesktopService.java

示例15: run

import com.sun.jna.platform.win32.WinUser; //导入依赖的package包/类
public void run(final String command, final String parameters, final String workingDirectory)
        throws SystemException {
    final WinDef.INT_PTR result = shell32.ShellExecute(
        null,
        "open",
        Objects.requireNonNull(command),
        Objects.requireNonNull(parameters),
        workingDirectory,
        WinUser.SW_SHOWNORMAL
    );
    if (result.intValue() <= 32) {
        throw new SystemException("Could not run command: " + command + " " + parameters);
    }
}
 
开发者ID:msiedlarek,项目名称:winthing,代码行数:15,代码来源:SystemService.java


注:本文中的com.sun.jna.platform.win32.WinUser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。