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


Java WinDef.HWND属性代码示例

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


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

示例1: capture

/**
 * 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,代码行数:25,代码来源:Utils.java

示例2: testStartProcess_Starts_Notepad

@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,代码行数:16,代码来源:UtilsTest.java

示例3: testQuitProcess_Quits_Notepad

@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,代码行数:16,代码来源:UtilsTest.java

示例4: testCloseWindow_Closes_Notepad

@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,代码行数:16,代码来源:UtilsTest.java

示例5: reloadSessions

private void reloadSessions() {
   WinDef.HWND hwnd = new WinDef.HWND(Native.getWindowPointer(MainFrame.this));
   WinDef.HMENU systemMenu = user32.GetSystemMenu(hwnd, new WinDef.BOOL(0));
   if (sessionsSeparatorPos > 0) {
      for (int i = sessionsSeparatorPos; i >= 0; i--) {
         user32.DeleteMenu(systemMenu, new WinDef.UINT(i), User32.MF_BYPOSITION);
      }
   }
   mapCustomMenuHandlers.clear();
   sessionsSeparatorPos = 0;
   try {
      File kittyHomeFile = new File(kittyHome);
      if (kittyHomeFile.isDirectory()) {
         for (File sessions : kittyHomeFile.listFiles()) {
            if (sessions.isDirectory() && "Sessions".equals(sessions.getName())) {
               sessionsSeparatorPos = loadSessions(systemMenu, mapCustomMenuHandlers, "", sessions, 0);
               if (sessionsSeparatorPos > 0) {
                  WinUtil.InsertMenuSeparator(systemMenu, sessionsSeparatorPos, ++CUSTOM_MENU_LAST_ID);
               }
            }
         }
      }
   } catch (UnsupportedEncodingException ex) {
      throw new RuntimeException("Error reloading esssions!", ex);
   }
}
 
开发者ID:vanjadardic,项目名称:KiTTY2,代码行数:26,代码来源:MainFrame.java

示例6: findChildWindowByText

public static WindowHolder findChildWindowByText(WindowHolder parenWindow, String text) {
	WinDef.DWORD fiveButton = new WinDef.DWORD(Long.parseLong(text));
	WinDef.HWND fiveButtonWnd = user32.GetWindow(parenWindow.getParentWindow(), fiveButton);
	if (fiveButtonWnd == null) {
		return null;
	}
	WINDOWINFO pwi = new WINDOWINFO();
	System.out.println(user32.GetWindowInfo(fiveButtonWnd, pwi));
	WindowHolder windowHolder = new WindowHolder(fiveButtonWnd, pwi);
	return windowHolder;
}
 
开发者ID:frolovm,项目名称:poker-bot,代码行数:11,代码来源:User32Utils.java

示例7: closeWindow

/**
 * 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,代码行数:13,代码来源:Utils.java

示例8: setTransparency

/**
 * Sets transparency of the window.
 * @param alpha 0..255 alpha attribute.
 * @throws Win32Exception WIN32 call has failed.
 * @throws AutomationException Something is wrong in automation.
 */
public void setTransparency(int alpha) throws Win32Exception, AutomationException {
    WinDef.HWND hwnd = this.getNativeWindowHandle();

    if (user32.SetWindowLong(hwnd, User32.GWL_EXSTYLE, User32.WS_EX_LAYERED) == 0) {
        throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
    }

    if (!user32.SetLayeredWindowAttributes(hwnd, 0, (byte)alpha, User32.LWA_ALPHA)) {
        throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
    }
}
 
开发者ID:mmarquee,项目名称:ui-automation,代码行数:17,代码来源:AutomationWindow.java

示例9: close

/**
 * Closes the window.
 *
 * @param title Title of the window to close.
 */
public void close(final String title) {
    if (user32 == null) {
        user32 = User32.INSTANCE;
    }

    WinDef.HWND hwnd = user32.FindWindow(null, title);

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

示例10: quit

/**
 * Quits the process.
 *
 * @param title Title of the window of the process to quit.
 */
public void quit(final String title) {
    if (user32 == null) {
        user32 = User32.INSTANCE;
    }

    WinDef.HWND hwnd = user32.FindWindow(null, title);

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

示例11: setTransparent

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,代码行数:7,代码来源:TestOpaque.java

示例12: cleanUp

@After
public void cleanUp() {
	
	while (true) {
		WinDef.HWND hwnd = User32.INSTANCE.FindWindow(null, getLocal("notepad.title"));
		if (hwnd == null) {
			break;
		}
        Utils.closeWindow(hwnd);
	}
}
 
开发者ID:mmarquee,项目名称:ui-automation,代码行数:11,代码来源:BaseAutomationTest.java

示例13: tearDown

@After
public void tearDown() {
    // Must be a better way of doing this????
    this.andRest();

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

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

示例14: getHWnd

/**
 * Get the window handle from the OS
 */
private static WinDef.HWND getHWnd(Component w) {
    WinDef.HWND hwnd = new WinDef.HWND();
    hwnd.setPointer(Native.getComponentPointer(w));
    return hwnd;
}
 
开发者ID:Exslims,项目名称:MercuryTrade,代码行数:8,代码来源:TestOpaque.java

示例15: getHWnd

private static WinDef.HWND getHWnd(Component w) {
    WinDef.HWND hwnd = new WinDef.HWND();
    hwnd.setPointer(Native.getComponentPointer(w));
    return hwnd;
}
 
开发者ID:Exslims,项目名称:MercuryTrade,代码行数:5,代码来源:AbstractAdrFrame.java


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