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


Java HWND类代码示例

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


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

示例1: init

import com.sun.jna.platform.win32.WinDef.HWND; //导入依赖的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.WinDef.HWND; //导入依赖的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.WinDef.HWND; //导入依赖的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: capture

import com.sun.jna.platform.win32.WinDef.HWND; //导入依赖的package包/类
/**
 * Captures the window.
 *
 * @param hwnd The window to capture.
 * @param filename Name to save the output into.
 * @throws AWTException Robot exception.
 * @throws IOException IO Exception.
 */
public static void capture(final WinDef.HWND hwnd,
                           final String filename)
        throws AWTException, IOException, Win32Exception {
    ensureWinApiInstances();
    
    WinDef.RECT rect = new WinDef.RECT();

    if (!user32.GetWindowRect(hwnd, rect)) {
        throw new Win32Exception(kernel32.GetLastError());
    }

    Rectangle rectangle = new Rectangle(rect.left, rect.top, rect.right -rect.left, rect.bottom -rect.top);

    BufferedImage image = new Robot().createScreenCapture(rectangle);

    ImageIO.write(image, "png", new File(filename));
}
 
开发者ID:mmarquee,项目名称:ui-automation,代码行数:26,代码来源:Utils.java

示例5: testStartProcess_Starts_Notepad

import com.sun.jna.platform.win32.WinDef.HWND; //导入依赖的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

示例6: testQuitProcess_Quits_Notepad

import com.sun.jna.platform.win32.WinDef.HWND; //导入依赖的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

示例7: testCloseWindow_Closes_Notepad

import com.sun.jna.platform.win32.WinDef.HWND; //导入依赖的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

示例8: getNativeWindowHandles

import com.sun.jna.platform.win32.WinDef.HWND; //导入依赖的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

示例9: capture

import com.sun.jna.platform.win32.WinDef.HWND; //导入依赖的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

示例10: isExitAndExecute

import com.sun.jna.platform.win32.WinDef.HWND; //导入依赖的package包/类
/**
 * Executes a command.
 * TODO: list possible commands and arguments
 *
 * @param input
 * 			A command without its colon at the beginning
 * @return True if the command requests the program to exit.
 */
public boolean isExitAndExecute(String input) {
	String[] args = input.split(" ");
	String cmd = args[0];
	if (cmd.equals("exit")) {
		return true;
	} else if (cmd.equals("focus")) {
		synchronized(mainWindow) {
			mainWindow.setVisible(true);
			mainWindow.toFront();
		}
	} else if (cmd.equals("hide")) {
		List<HWND> windowsToHide = WindowsUtils.findByTitle(args[1]);
		for (HWND window : windowsToHide) {
			WindowsUtils.setVisible(window, false);
		}
	}
	return false;
}
 
开发者ID:MX-Futhark,项目名称:hook-any-text,代码行数:27,代码来源:CommandInterpreter.java

示例11: EnumerateWin32ChildWindows

import com.sun.jna.platform.win32.WinDef.HWND; //导入依赖的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

示例12: getControlText

import com.sun.jna.platform.win32.WinDef.HWND; //导入依赖的package包/类
public static String getControlText(HWND hCtrl) {
	String text = null;
	if (isHWnd(hCtrl)) {
		int textLength = user32.SendMessage(hCtrl, WM_GETTEXTLENGTH, 0, 0);
		if (textLength == 0) {
			text = "";
		} else {
			char[] lpText = new char[textLength + 1];
			if (textLength == user32.SendMessage(hCtrl, WM_GETTEXT,
					lpText.length, lpText)) {
				text = new String(lpText, 0, textLength);
			}
		}
	}
	return text;
}
 
开发者ID:wangzhengbo,项目名称:JAutoItX,代码行数:17,代码来源:Win32.java

示例13: registerAllHotKeys

import com.sun.jna.platform.win32.WinDef.HWND; //导入依赖的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

示例14: getClassName

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

	// run notepad
	int pid = runNotepad();

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

	Assert.assertEquals(NOTEPAAD_CLASS_NAME,
			Win.getClassName(NOTEPAD_TITLE));
	Assert.assertEquals(NOTEPAAD_CLASS_NAME, Win.getClassName(hWnd));

	// close notepad
	closeNotepad(pid);

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

示例15: createWindow

import com.sun.jna.platform.win32.WinDef.HWND; //导入依赖的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


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