public void reboot() { setShutdownPrivileges(); if (!MyUser32.INSTANCE.ExitWindowsEx(new UINT(MyUser32.INSTANCE.EWX_REBOOT + MyUser32.INSTANCE.EWX_FORCE), new DWORD(MyUser32.INSTANCE.SHTDN_REASON_FLAG_PLANNED)).booleanValue()) { int err = MyKernel32.INSTANCE.GetLastError(); System.out.println("error executing reboot "+err+ " "+Kernel32Util.formatMessageFromLastErrorCode(err)); } }
public void LockSetForegroundWindow(int uLockCode) { User32Ext.INSTANCE.LockSetForegroundWindow(new UINT(uLockCode)); }
private void setVisible(boolean show) { if (show) { timer.schedule(new TimerTask() { public void run() { window.bringWindowToTop(); } }, 50); timer.schedule(new TimerTask() { INPUT input = null; public void run() { if (input == null) { int INPUT_MOUSE = 0; int MOUSEEVENTF_MOVE = 0x1; int MOUSEEVENTF_ABSOLUTE = 0x08000; int MOUSEEVENTF_LEFTDOWN = 0x2; int MOUSEEVENTF_LEFTUP = 0x4; input = new INPUT(); input.type = new DWORD(INPUT_MOUSE); // TODO get current position input.input.mi.dx = new LONG(config.x + 10); input.input.mi.dy = new LONG(config.y + 10); input.input.mi.dwFlags = new DWORD(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP); } // Put window on the top window.setForegroundWindow(); // Simulate click to set focus User32Ext.INSTANCE.SendInput(new UINT(1), input, input.size()); } }, 100); } else { timer.schedule(new TimerTask() { public void run() { window.showWindow(SW_HIDE); } }, 50); } isHidden = !show; }
/** * Checks to see if the item expanded. * * @param title * The title of the window to access. * @param text * The text of the window to access. * @param control * The control to interact with. * @param item * The "item" parameter is a string-based parameter that is used * to reference a particular treeview item using a combination of * text and indices. Indices are 0-based. For example:<br/> * Heading1<br/> * ----> H1SubItem1<br/> * ----> H1SubItem2<br/> * ----> H1SubItem3<br/> * ----> ----> H1S1SubItem1<br/> * Heading2<br/> * Heading3<br/> * * Each "level" is separated by |. An index is preceded with #. * Examples:<br/> * * <table> * <thead> * <tr> * <td>Item</td> * <td>Item Reference</td> * </tr> * </thead> * <tr> * <td>Heading2</td> * <td>"Heading2" or "#1"</td> * </tr> * <tr> * <td>H1SubItem2</td> * <td>"Heading1|H1SubItem2" or "#0|#1"</td> * </tr> * <tr> * <td>H1S1SubItem1</td> * <td>"Heading1|H1SubItem3|H1S1SubItem1" or "#0|#2|#0"</td> * </tr> * </table> * * References can also be mixed like "Heading1|#1". * @return Returns true if item is expanded, otherwise return false. */ public static boolean isExpanded(final String title, final String text, final String control, final String item) { boolean expanded = false; HWND hWnd = Control.getHandle_(title, text, control); if (hWnd != null) { HWND itemHWND = getHandle(title, text, control, item); if (itemHWND != null) { TVITEM treeViewItem = new TVITEM(); treeViewItem.mask = new UINT(TVIF_STATE); treeViewItem.hItem = (int) Pointer.nativeValue(itemHWND .getPointer()); Win32.user32.SendMessage(hWnd, TVM_GETITEMW, new WPARAM(0), treeViewItem); expanded = ((treeViewItem.state.intValue() & TVIS_EXPANDED) != 0); } } return expanded; }
UINT ExtractIconEx(String lpszFile, int nIconIndex, PointerByReference phiconLarge, PointerByReference phiconSmall, UINT nIcons);