本文整理汇总了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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
示例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());
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例15: getHWnd
private static WinDef.HWND getHWnd(Component w) {
WinDef.HWND hwnd = new WinDef.HWND();
hwnd.setPointer(Native.getComponentPointer(w));
return hwnd;
}