本文整理汇总了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;
}
示例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);
}
}
示例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");
}
}
示例4: ensureWinApiInstances
private static void ensureWinApiInstances() {
if (user32 == null) {
user32 = User32.INSTANCE;
}
if (kernel32 == null) {
kernel32 = Kernel32.INSTANCE;
}
}
示例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();
}
示例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));
}
示例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);
}
}
示例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);
}
示例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());
}
}
示例10: WindowsMonitorManager
public WindowsMonitorManager() throws UnsupportedOperatingSystemException {
if (!Platform.isWindows()) {
throw new UnsupportedOperatingSystemException("Windows", System.getProperty("os.name"));
}
USER32 = User32.INSTANCE;
DXVA2 = Dxva2.INSTANCE;
}
示例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;
}
示例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;
}
示例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();
}
示例14: setupJNA
/**
* One-time JNA setup.
*/
private static void setupJNA() {
if (PlatformSpecific.isOnWindows()) user32 = User32.INSTANCE;
}
示例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();
}