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


Java User32.INSTANCE属性代码示例

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


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

示例1: findWind

public static HWND findWind(final String name) {
 final User32 user32 = User32.INSTANCE;
 title=null;
 wind = null;
 user32.EnumWindows(new WNDENUMPROC() {
     public boolean callback(HWND hWnd, Pointer arg1) {
         char[] windowText = new char[512];
         user32.GetWindowText(hWnd, windowText, 512);
         String wText = Native.toString(windowText);
         if (wText.contains(name)) {
       	  title = wText;
       	  wind = hWnd;
       	  return false;
         }
         return true;
     }
 }, null);
 return wind;
}
 
开发者ID:lawrie,项目名称:HouseControl,代码行数:19,代码来源:ActivateWindow.java

示例2: quit

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

示例3: bringHandleToFront

public void bringHandleToFront(HWND selectedWindow) {
    User32 user32 = User32.INSTANCE;
    User32Ext myuser32 = User32Ext.INSTANCE;
    Kernel32 k32 = Kernel32.INSTANCE;
    boolean result = true;
    int foreThread = myuser32.GetWindowThreadProcessId(myuser32.GetForegroundWindow(), null);
    int targetThread = myuser32.GetWindowThreadProcessId(selectedWindow, null);
    int appThread = k32.GetCurrentThreadId();
    if (SwingUtilities.isEventDispatchThread()) {
        System.out.println("is the event dispatch thread.");
    }
    if (foreThread != appThread) {
        System.out.printf("Proc Handler: Fore %d App %d target %d\n", foreThread, appThread, targetThread);
        System.out.println("Selected window name " + User32ExtUtil.getWindowText(selectedWindow));
        System.out.println("Foreground and app thread different.");
        result = myuser32.AttachThreadInput(appThread, foreThread, true);
        result = myuser32.AttachThreadInput(targetThread, appThread, true);
        processResult(result, "AttachThreadInput");
        result = myuser32.ShowWindow(selectedWindow, WinUserExt.SW_RESTORE);
        //result = myuser32.BringWindowToTop(selectedWindow);
        result = myuser32.SetForegroundWindow(selectedWindow);

        //myuser32.SwitchToThisWindow(selectedWindow, false);
        //myuser32.BringWindowToTop(selectedWindow);
        //processResult(result, "BringWindowToTop");
        result = myuser32.AttachThreadInput(appThread, foreThread, false);
        result = myuser32.AttachThreadInput(targetThread, appThread, false);
        processResult(result, "DetachThreadInput");
    } else {
        System.out.println("Foreground and app thread alike.");
        result = myuser32.SetForegroundWindow(selectedWindow);
        processResult(result, "SetForegroundWindow");

    }
}
 
开发者ID:PM-Master,项目名称:Harmonia-1.5,代码行数:35,代码来源:ProcessHandler.java

示例4: ensureWinApiInstances

private static void ensureWinApiInstances() {
	if (user32 == null) {
           user32 = User32.INSTANCE;
       }
	if (kernel32 == null) {
		kernel32 = Kernel32.INSTANCE;
       }
}
 
开发者ID:mmarquee,项目名称:ui-automation,代码行数:8,代码来源:Utils.java

示例5: AutomationWindow

/**
 * Constructor for the AutomationWindow.
 * @param builder The builder
 */
public AutomationWindow (ElementBuilder builder) {
    super(builder);

    if (builder.getHasUser32()) {
        this.user32 = builder.getUser32();
    } else {
        this.user32 = User32.INSTANCE;
    }
    this.windowPattern = builder.getWindow();
}
 
开发者ID:mmarquee,项目名称:ui-automation,代码行数:14,代码来源:AutomationWindow.java

示例6: waitForInputIdle

/**
 * Waits for the application to accept input, i.e. not be idle.
 * @param timeout Timeout to wait for.
 */
public void waitForInputIdle(final int timeout) {
    if (user32 == null) {
        user32 = User32.INSTANCE;
    }
    user32.WaitForInputIdle(this.handle, new WinDef.DWORD(timeout));
}
 
开发者ID:mmarquee,项目名称:ui-automation,代码行数:10,代码来源:AutomationApplication.java

示例7: 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

示例8: WindowsXPMouse

public WindowsXPMouse()
{
	if (!Platform.isWindows())
	{
		throw new UnsupportedOperationException(
				"Not supported on this platform.");
	}
	USER32INST = User32.INSTANCE;
	KERNEL32INST = Kernel32.INSTANCE;
	mouseHook = hookTheMouse();
	Native.setProtected(true);

}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:13,代码来源:WindowsXPMouse.java

示例9: initCoreClasses

private void initCoreClasses() throws Exception {
    try {
        libU = User32.INSTANCE;
        libK = Kernel32.INSTANCE;
    } catch (java.lang.UnsatisfiedLinkError | java.lang.NoClassDefFoundError ex) {
        TrayProcess.handleException(ex);
        throw new Exception(ex.toString());
    }
}
 
开发者ID:martin-lizner,项目名称:trezor-ssh-agent,代码行数:9,代码来源:SSHAgent.java

示例10: WindowsMonitorManager

public WindowsMonitorManager() throws UnsupportedOperatingSystemException {
    if (!Platform.isWindows()) {
        throw new UnsupportedOperatingSystemException("Windows", System.getProperty("os.name"));
    }

    USER32 = User32.INSTANCE;
    DXVA2 = Dxva2.INSTANCE;
}
 
开发者ID:pitkley,项目名称:jmccs-win,代码行数:8,代码来源:WindowsMonitorManager.java

示例11: activate

public static String activate(String app) {
  User32 user32 = User32.INSTANCE;
  HWND hWnd = findWind(app);
  user32.ShowWindow(hWnd, User32.SW_SHOWMAXIMIZED);
  user32.SetForegroundWindow(hWnd);
  return title;
}
 
开发者ID:lawrie,项目名称:HouseControl,代码行数:7,代码来源:ActivateWindow.java

示例12: getWindowText

/**
 * Gets the title of a window in a String
 * @param window - a HWND reference of a window
 * @return - the title of the window as a String
 */
public static String getWindowText(HWND window) {
    User32 user32 = User32.INSTANCE;
    char[] chars = new char[user32.GetWindowTextLength(window) + 1];
    user32.GetWindowText(window, chars, chars.length);
    String windowName = new String(chars, 0, chars.length - 1);
    return windowName;
}
 
开发者ID:PM-Master,项目名称:Harmonia-1.5,代码行数:12,代码来源:User32ExtUtil.java

示例13: repopulateNameWindowMap

private void repopulateNameWindowMap() {
    final List<HWND> windows = new ArrayList<HWND>();
    nameWindowMap = new HashMap<String, HWND>();
    User32 user32 = User32.INSTANCE;
    User32Ext myuser32 = User32Ext.INSTANCE;
    Kernel32 k32 = Kernel32.INSTANCE;
    getWindowNameMap(windows, user32, nameWindowMap);
    for (ListDataListener listener : ((AbstractListModel) this.jList1.getModel()).getListDataListeners()) {
        listener.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, nameWindowMap.keySet().size() - 1));
    }
    //this.jScrollPane1.revalidate();
    //this.jScrollPane1.repaint();
}
 
开发者ID:PM-Master,项目名称:Harmonia-1.5,代码行数:13,代码来源:ProcessHandler.java

示例14: setupJNA

/**
 * One-time JNA setup.
 */
private static void setupJNA() {
    if (PlatformSpecific.isOnWindows()) user32 = User32.INSTANCE;
}
 
开发者ID:HubTurbo,项目名称:HubTurbo,代码行数:6,代码来源:BrowserComponent.java

示例15: initKeyHook

public void initKeyHook() {

	    thread = new Thread(new Runnable() {

		@Override
		public void run() {
		    final User32 lib = User32.INSTANCE;
		    HMODULE hMod = Kernel32.INSTANCE.GetModuleHandle(null);
		    keyboardHook = new LowLevelKeyboardProc() {
			public LRESULT callback(int nCode, WPARAM wParam,
				KBDLLHOOKSTRUCT info) {
			    if (nCode >= 0) {
				switch (wParam.intValue()) {
				// case WinUser.WM_KEYUP:
				case WinUser.WM_KEYDOWN:
				    // case WinUser.WM_SYSKEYUP:
				case WinUser.WM_SYSKEYDOWN:
				    // do active
				    userActive();
				}
			    }
			    return lib.CallNextHookEx(hhk, nCode, wParam,
				    info.getPointer());
			}
		    };
		    hhk = lib.SetWindowsHookEx(WinUser.WH_KEYBOARD_LL,
			    keyboardHook, hMod, 0);

		    // This bit never returns from GetMessage
		    int result;
		    MSG msg = new MSG();
		    while ((result = lib.GetMessage(msg, null, 0, 0)) != 0) {
			if (result == -1) {
			    System.err.println("error in get message");
			    break;
			} else {
			    System.err.println("got message");
			    lib.TranslateMessage(msg);
			    lib.DispatchMessage(msg);
			}
		    }
		    lib.UnhookWindowsHookEx(hhk);
		}
	    });
	    thread.start();
	}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:46,代码来源:UserIdlePlugin.java


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