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


Java User32类代码示例

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


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

示例1: init

import com.sun.jna.platform.win32.User32; //导入依赖的package包/类
@Override
public void init() {
	super.init();
	WindowManager.createWindow(handle, window, true);

	long hwndGLFW = glfwGetWin32Window(window.getID());
	HWND hwnd = new HWND(Pointer.createConstant(hwndGLFW));

	WindowProc proc = new WindowProc() {

		@Override
		public long invoke(long hw, int uMsg, long wParam, long lParam) {
			if (hw == hwndGLFW)
				switch (uMsg) {
				case WM_WINDOWPOSCHANGING:
					WINDOWPOS pos = new WINDOWPOS(new Pointer(lParam));
					pos.flags |= SWP_NOZORDER | SWP_NOACTIVATE;
					pos.write();
					break;
				}
			return org.lwjgl.system.windows.User32.DefWindowProc(hw, uMsg, wParam, lParam);
		}
	};
	User32.INSTANCE.SetWindowLongPtr(hwnd, GWL_WNDPROC, Pointer.createConstant(proc.address()));
	User32Ext.INSTANCE.SetWindowLongPtr(hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
	User32Ext.INSTANCE.SetWindowLongPtr(hwnd, GWL_STYLE, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);

	User32.INSTANCE.SetWindowPos(hwnd, new HWND(Pointer.createConstant(HWND_BOTTOM)), 0, 0, 0, 0,
			SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
	wallpaper = window.getResourceLoader().loadNVGTexture(getCurrentDesktopWallpaper(), true);
	TaskManager.addTask(() -> window.setVisible(true));
}
 
开发者ID:Guerra24,项目名称:NanoUI,代码行数:33,代码来源:Background.java

示例2: getAppUserModelId

import com.sun.jna.platform.win32.User32; //导入依赖的package包/类
public static String getAppUserModelId(HWND hwnd) {
	IntByReference processID = new IntByReference();
	User32.INSTANCE.GetWindowThreadProcessId(hwnd, processID);
	HANDLE hProcess = Kernel32.INSTANCE.OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, processID.getValue());
	UINTByReference length = new UINTByReference();
	Kernel32Ext.INSTANCE.GetApplicationUserModelId(hProcess, length, null);
	char[] modelID = new char[length.getValue().intValue()];
	Kernel32Ext.INSTANCE.GetApplicationUserModelId(hProcess, length, modelID);
	return new String(Native.toString(modelID));
}
 
开发者ID:Guerra24,项目名称:NanoUI,代码行数:11,代码来源:Util.java

示例3: createHotKeys

import com.sun.jna.platform.win32.User32; //导入依赖的package包/类
private void createHotKeys() {
	Thread keys = new Thread(() -> {
		keysThreadID = Kernel32.INSTANCE.GetCurrentThreadId();
		User32.INSTANCE.RegisterHotKey(new HWND(Pointer.NULL), 1, MOD_WIN | MOD_NOREPEAT, VK_E);
		MSG msg = new MSG();
		while (User32.INSTANCE.GetMessage(msg, new HWND(Pointer.NULL), 0, 0) != 0 && running) {
			if (msg.message == WM_HOTKEY) {
				try {
					switch (msg.wParam.intValue()) {
					case 1:
						new ProcessBuilder("explorer.exe", ",").start();
						break;
					}
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		User32.INSTANCE.UnregisterHotKey(Pointer.NULL, 1);
	});
	keys.start();
}
 
开发者ID:Guerra24,项目名称:NanoUI,代码行数:23,代码来源:TaskBar.java

示例4: dispose

import com.sun.jna.platform.win32.User32; //导入依赖的package包/类
@Override
public void dispose() {
	super.dispose();
	window.dispose(AppUI.getMainWindow());
	if (ENABLED_NOTIFICATIONS)
		TrayHook.INSTANCE.UnregisterSystemTrayHook();
	User32Ext.INSTANCE.SystemParametersInfo(SPI.SPI_SETWORKAREA, 0, old.getPointer(), 0);
	User32Ext.INSTANCE.DeregisterShellHookWindow(local);
	if (noExplorer) {
		backgroundWindow.getWindow().closeDisplay();
		User32.INSTANCE.PostThreadMessage(keysThreadID, WM_QUIT, new WPARAM(), new LPARAM());
		User32Ext.INSTANCE.SystemParametersInfo(SPI.SPI_SETMINIMIZEDMETRICS, oldMM.size(), oldMM.getPointer(), 0);
	} else {
		if (taskbar != null)
			User32.INSTANCE.ShowWindow(taskbar, SW_SHOW);
	}
}
 
开发者ID:Guerra24,项目名称:NanoUI,代码行数:18,代码来源:TaskBar.java

示例5: quit

import com.sun.jna.platform.win32.User32; //导入依赖的package包/类
/**
 * Quits the process.
 *
 * @param titlePattern a pattern matching the title of the window of the process to quit
 */
public void quit(final Pattern titlePattern) {
    if (user32 == null) {
        user32 = User32.INSTANCE;
    }

    final WinDef.HWND handle = Utils.findWindow(null, titlePattern);

    if (handle != null) {
        Utils.quitProcess(handle);
    }
}
 
开发者ID:mmarquee,项目名称:ui-automation,代码行数:17,代码来源:AutomationApplication.java

示例6: testStartProcess_Starts_Notepad

import com.sun.jna.platform.win32.User32; //导入依赖的package包/类
@Test
public void testStartProcess_Starts_Notepad() {
    try {
        Utils.startProcess("notepad.exe");

        this.andRest();

        WinDef.HWND hwnd = User32.INSTANCE.FindWindow(null, getLocal("notepad.title"));

        assertTrue("startProcess - no process", hwnd != null);
    } catch (IOException io) {
        assertTrue("startProcess: " + io.getMessage(), false);
    }

    assertTrue("startProcess", true);
}
 
开发者ID:mmarquee,项目名称:ui-automation,代码行数:17,代码来源:UtilsTest.java

示例7: testQuitProcess_Quits_Notepad

import com.sun.jna.platform.win32.User32; //导入依赖的package包/类
@Test
public void testQuitProcess_Quits_Notepad() {
    try {
        Utils.startProcess("notepad.exe");

        WinDef.HWND hwnd = User32.INSTANCE.FindWindow(null, getLocal("notepad.title"));

        if (hwnd != null) {
            Utils.quitProcess(hwnd);
        }
    } catch (IOException io) {
        assertTrue("quitProcess: " + io.getMessage(), false);
    }

    assertTrue("quitProcess", true);
}
 
开发者ID:mmarquee,项目名称:ui-automation,代码行数:17,代码来源:UtilsTest.java

示例8: testCloseWindow_Closes_Notepad

import com.sun.jna.platform.win32.User32; //导入依赖的package包/类
@Test
public void testCloseWindow_Closes_Notepad() {
    try {
        Utils.startProcess("notepad.exe");

        WinDef.HWND hwnd = User32.INSTANCE.FindWindow(null, getLocal("notepad.title"));

        if (hwnd != null) {
            Utils.closeWindow(hwnd);
        }
    } catch (IOException io) {
        assertTrue("quitProcess: " + io.getMessage(), false);
    }

    assertTrue("quitProcess", true);
}
 
开发者ID:mmarquee,项目名称:ui-automation,代码行数:17,代码来源:UtilsTest.java

示例9: gameToFront

import com.sun.jna.platform.win32.User32; //导入依赖的package包/类
private void gameToFront() {
    User32.INSTANCE.EnumWindows((hWnd, arg1) -> {
        char[] className = new char[512];
        User32.INSTANCE.GetClassName(hWnd, className, 512);
        String wText = Native.toString(className);

        if (wText.isEmpty()) {
            return true;
        }
        if (wText.equals("POEWindowClass")) {
            User32.INSTANCE.SetForegroundWindow(hWnd);
            return false;
        }
        return true;
    }, null);
}
 
开发者ID:Exslims,项目名称:MercuryTrade,代码行数:17,代码来源:ChatHelper.java

示例10: createWindowsProcess

import com.sun.jna.platform.win32.User32; //导入依赖的package包/类
private HWND createWindowsProcess() {

        WString windowClass = new WString(APPNAME);
        HMODULE hInst = libK.GetModuleHandle("");
        WNDCLASSEX wndclass = new WNDCLASSEX();
        wndclass.hInstance = hInst;
        wndclass.lpfnWndProc = SSHAgent.this;
        wndclass.lpszClassName = windowClass;
        // register window class
        libU.RegisterClassEx(wndclass);
        getLastError();
        // create new window
        HWND winprocess = libU
                .CreateWindowEx(
                        User32.WS_OVERLAPPED,
                        windowClass,
                        APPNAME,
                        0, 0, 0, 0, 0,
                        null, // WM_DEVICECHANGE contradicts parent=WinUser.HWND_MESSAGE
                        null, hInst, null);

        mutex = libK.CreateMutex(null, false, MUTEX_NAME);
        return winprocess;
    }
 
开发者ID:martin-lizner,项目名称:trezor-ssh-agent,代码行数:25,代码来源:SSHAgent.java

示例11: getNativeWindowHandles

import com.sun.jna.platform.win32.User32; //导入依赖的package包/类
/**
 * Gets the native window handles.
 *
 * @return the native window handles
 */
private void getNativeWindowHandles()
{

	SwingUtilities.invokeLater(new Runnable()
	{
		@Override
		public void run()
		{
			HWND fgWindow = User32.INSTANCE.GetForegroundWindow();
			int titleLength = User32.INSTANCE.GetWindowTextLength(fgWindow) + 1;
			char[] title = new char[titleLength];
			User32.INSTANCE.GetWindowText(fgWindow, title, titleLength);
			int awtCanvasHandle = (int) Pointer.nativeValue(fgWindow.getPointer());
			setApplicationHandle(awtCanvasHandle);
		}
	});
}
 
开发者ID:synergynet,项目名称:synergynet3.1,代码行数:23,代码来源:Win7NativeTouchSource.java

示例12: capture

import com.sun.jna.platform.win32.User32; //导入依赖的package包/类
public BufferedImage capture(final HWND hWnd) {

        final HDC hdcWindow = User32.INSTANCE.GetDC(hWnd);
        final HDC hdcMemDC = GDI32.INSTANCE.CreateCompatibleDC(hdcWindow);

        final RECT bounds = new RECT();
        User32Extra.INSTANCE.GetClientRect(hWnd, bounds);

        final int width = bounds.right - bounds.left;
        final int height = bounds.bottom - bounds.top;
        if (width * height <= 0) { return null; }
        final HBITMAP hBitmap = GDI32.INSTANCE.CreateCompatibleBitmap(hdcWindow, width, height);

        final HANDLE hOld = GDI32.INSTANCE.SelectObject(hdcMemDC, hBitmap);
        GDI32Extra.INSTANCE.BitBlt(hdcMemDC, 0, 0, width, height, hdcWindow, 0, 0, WinGDIExtra.SRCCOPY);

        GDI32.INSTANCE.SelectObject(hdcMemDC, hOld);
        GDI32.INSTANCE.DeleteDC(hdcMemDC);

        final BITMAPINFO bmi = new BITMAPINFO();
        bmi.bmiHeader.biWidth = width;
        bmi.bmiHeader.biHeight = -height;
        bmi.bmiHeader.biPlanes = 1;
        bmi.bmiHeader.biBitCount = 32;
        bmi.bmiHeader.biCompression = WinGDI.BI_RGB;

        final Memory buffer = new Memory(width * height * 4);
        GDI32.INSTANCE.GetDIBits(hdcWindow, hBitmap, 0, height, buffer, bmi, WinGDI.DIB_RGB_COLORS);

        final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        image.setRGB(0, 0, width, height, buffer.getIntArray(0, width * height), 0, width);

        GDI32.INSTANCE.DeleteObject(hBitmap);
        User32.INSTANCE.ReleaseDC(hWnd, hdcWindow);

        return image;

    }
 
开发者ID:friedlwo,项目名称:AppWoksUtils,代码行数:39,代码来源:Paint.java

示例13: createHotKeysHook

import com.sun.jna.platform.win32.User32; //导入依赖的package包/类
public void createHotKeysHook() {
	registerAllHotKeys();
	//User32Ex.instance.MsgWaitForMultipleObjects(0, Pointer.NULL, true, INFINITE, QS_HOTKEY);

	//System.out.println("starting message loop");
	MSG msg = new MSG();
	try {
		
		while (!quit) {
			User32.INSTANCE.PeekMessage(msg, null, 0, 0, 1);
			if (msg.message == User32.WM_HOTKEY){ // && msg.wParam.intValue() == 1
				//System.out.println("Hot key pressed " + msg.wParam);
				TargetKeyPress target = findTargetKeyPressById(msg.wParam.intValue());
				if (target != null)
	    			events.keyPressed(target);
				msg = new MSG(); //must clear msg so it doesn't repeat
			}
			Thread.sleep(10);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	unregisterAllHotKeys();
	//System.out.println("message loop stopped");
}
 
开发者ID:Synthuse,项目名称:synthuse-src,代码行数:26,代码来源:KeyboardHook.java

示例14: registerAllHotKeys

import com.sun.jna.platform.win32.User32; //导入依赖的package包/类
private void registerAllHotKeys() // must register hot keys in the same thread that is watching for hotkey messages
{
	//System.out.println("registering hotkeys");
	for (TargetKeyPress tkp : KeyboardHook.targetList) {
		//BOOL WINAPI RegisterHotKey(HWND hWnd, int id, UINT fsModifiers, UINT vk);
		int modifiers = User32.MOD_NOREPEAT;
		if (tkp.withShift)
			modifiers = modifiers | User32.MOD_SHIFT;
		if (tkp.withCtrl)
			modifiers = modifiers | User32.MOD_CONTROL;
		if (tkp.withAlt)
			modifiers = modifiers | User32.MOD_ALT;
		//System.out.println("RegisterHotKey " + tkp.idNumber + "," + modifiers + ", " + tkp.targetKeyCode);
		
		if (!User32.INSTANCE.RegisterHotKey(new WinDef.HWND(Pointer.NULL), tkp.idNumber, modifiers, tkp.targetKeyCode))
		{
            System.out.println("Couldn't register hotkey " + tkp.targetKeyCode);
		}
	}
}
 
开发者ID:Synthuse,项目名称:synthuse-src,代码行数:21,代码来源:KeyboardHook.java

示例15: getHandle

import com.sun.jna.platform.win32.User32; //导入依赖的package包/类
@Test
public void getHandle() {
	Assert.assertNull(Win.getHandle(NOTEPAD_TITLE));
	Assert.assertNull(Win.getHandle((HWND) null));

	// run notepad
	int pid = runNotepad();

	HWND hWnd = Win.getHandle_(NOTEPAD_TITLE);
	Assert.assertNotNull(hWnd);

	assertEquals(
			AutoItX.hwndToHandle(User32.INSTANCE.GetForegroundWindow()),
			Win.getHandle(NOTEPAD_TITLE));
	assertEquals(
			AutoItX.hwndToHandle(User32.INSTANCE.GetForegroundWindow()),
			Win.getHandle(hWnd));

	// close notepad
	closeNotepad(pid);

	Assert.assertNull(Win.getHandle(NOTEPAD_TITLE));
	Assert.assertNull(Win.getHandle(hWnd));
}
 
开发者ID:wangzhengbo,项目名称:JAutoItX,代码行数:25,代码来源:WinTest.java


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