Java Examples for com.sun.jna.platform.win32.WinDef.WPARAM

The following java examples will help you to understand the usage of com.sun.jna.platform.win32.WinDef.WPARAM. These source code samples are taken from different open source projects.

Example 1
Project: btpka3.github.com-master  File: ComContainer.java View source code
public String enc(String password) {
    Kernel32 kernel32 = Kernel32.INSTANCE;
    User32 user32 = User32.INSTANCE;
    MyUser32 myUser32 = MyUser32.INSTANCE;
    kernel32.SetLastError(0);
    final int MAPVK_VK_TO_VSC = 0;
    // find the window handle of OleFrame
    HWND h = new HWND(new Pointer(clientSite.handle));
    // find the window handle of the ActiveX
    h = user32.GetWindow(h, new DWORD(User32.GW_CHILD));
    // find the window handle of the password input control
    h = user32.GetWindow(h, new DWORD(User32.GW_CHILD));
    OleAutomation ole = new OleAutomation(clientSite);
    init();
    // 清空密码
    t.setFocus();
    frame.setFocus();
    // send the new password string
    for (char c : password.toCharArray()) {
        int errorNo = 0;
        int tryTimes = 0;
        kernel32.SetLastError(0);
        do {
            LParamUnion lUnion = LParamUnion.getDefaultVmChar();
            lUnion.setScanCode((byte) myUser32.MapVirtualKey(VK.VK_A, MAPVK_VK_TO_VSC));
            MyUser32.INSTANCE.SendMessage(h, User32.WM_CHAR, new WPARAM(c), new LPARAM(lUnion.toInt()));
            tryTimes++;
            errorNo = kernel32.GetLastError();
        } while (errorNo != 0 && tryTimes < 3);
        if (errorNo != 0) {
            throw new RuntimeException("Could not complete the " + "password encoding. error code = " + errorNo);
        }
    }
    // get the encrypted password
    t.setFocus();
    int[] rgdispid = ole.getIDsOfNames(new String[] { "Password" });
    Variant var = ole.getProperty(rgdispid[0]);
    System.out.println("ddddddddddddd" + var);
    if (OLE.VT_NULL == var.getType()) {
        return null;
    } else if (OLE.VT_EMPTY == var.getType()) {
        return "";
    }
    return var.getString();
}
Example 2
Project: topsun-master  File: ScanBarcodeService.java View source code
@Override
public LRESULT callback(int nCode, WPARAM wParam, KBDLLHOOKSTRUCT info) {
    if (nCode >= 0) {
        switch(wParam.intValue()) {
            case WinUser.WM_KEYUP:
                int keyCode = info.vkCode;
                if (keyCode >= 48 && keyCode <= 57) {
                    listener.onKey(keyCode);
                }
                if (keyCode == 13) {
                    listener.onKey(keyCode);
                }
                break;
        }
    }
    return lib.CallNextHookEx(hhkKeyBoard, nCode, wParam, info.getPointer());
}
Example 3
Project: jna-mirror-master  File: KeyHook.java View source code
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:
                System.err.println("in callback, key=" + info.vkCode);
                if (info.vkCode == 81) {
                    quit = true;
                }
        }
    }
    return lib.CallNextHookEx(hhk, nCode, wParam, info.getPointer());
}
Example 4
Project: jna-master  File: WindowUtils.java View source code
@Override
public BufferedImage getWindowIcon(final HWND hwnd) {
    // request different kind of icons if any solution fails
    final DWORDByReference hIconNumber = new DWORDByReference();
    LRESULT result = User32.INSTANCE.SendMessageTimeout(hwnd, WinUser.WM_GETICON, new WPARAM(WinUser.ICON_BIG), new LPARAM(0), WinUser.SMTO_ABORTIFHUNG, 500, hIconNumber);
    if (result.intValue() == 0)
        result = User32.INSTANCE.SendMessageTimeout(hwnd, WinUser.WM_GETICON, new WPARAM(WinUser.ICON_SMALL), new LPARAM(0), WinUser.SMTO_ABORTIFHUNG, 500, hIconNumber);
    if (result.intValue() == 0)
        result = User32.INSTANCE.SendMessageTimeout(hwnd, WinUser.WM_GETICON, new WPARAM(WinUser.ICON_SMALL2), new LPARAM(0), WinUser.SMTO_ABORTIFHUNG, 500, hIconNumber);
    if (result.intValue() == 0) {
        result = new LRESULT(User32.INSTANCE.GetClassLongPtr(hwnd, WinUser.GCLP_HICON).intValue());
        hIconNumber.getValue().setValue(result.intValue());
    }
    if (result.intValue() == 0) {
        result = new LRESULT(User32.INSTANCE.GetClassLongPtr(hwnd, WinUser.GCLP_HICONSM).intValue());
        hIconNumber.getValue().setValue(result.intValue());
    }
    if (result.intValue() == 0)
        return null;
    // draw native icon into Java image
    final HICON hIcon = new HICON(new Pointer(hIconNumber.getValue().longValue()));
    final Dimension iconSize = getIconSize(hIcon);
    if (iconSize.width == 0 || iconSize.height == 0)
        return null;
    final int width = iconSize.width;
    final int height = iconSize.height;
    final short depth = 24;
    final byte[] lpBitsColor = new byte[width * height * depth / 8];
    final Pointer lpBitsColorPtr = new Memory(lpBitsColor.length);
    final byte[] lpBitsMask = new byte[width * height * depth / 8];
    final Pointer lpBitsMaskPtr = new Memory(lpBitsMask.length);
    final BITMAPINFO bitmapInfo = new BITMAPINFO();
    final BITMAPINFOHEADER hdr = new BITMAPINFOHEADER();
    bitmapInfo.bmiHeader = hdr;
    hdr.biWidth = width;
    hdr.biHeight = height;
    hdr.biPlanes = 1;
    hdr.biBitCount = depth;
    hdr.biCompression = 0;
    hdr.write();
    bitmapInfo.write();
    final HDC hDC = User32.INSTANCE.GetDC(null);
    final ICONINFO iconInfo = new ICONINFO();
    User32.INSTANCE.GetIconInfo(hIcon, iconInfo);
    iconInfo.read();
    GDI32.INSTANCE.GetDIBits(hDC, iconInfo.hbmColor, 0, height, lpBitsColorPtr, bitmapInfo, 0);
    lpBitsColorPtr.read(0, lpBitsColor, 0, lpBitsColor.length);
    GDI32.INSTANCE.GetDIBits(hDC, iconInfo.hbmMask, 0, height, lpBitsMaskPtr, bitmapInfo, 0);
    lpBitsMaskPtr.read(0, lpBitsMask, 0, lpBitsMask.length);
    final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    int r, g, b, a, argb;
    int x = 0, y = height - 1;
    for (int i = 0; i < lpBitsColor.length; i = i + 3) {
        b = lpBitsColor[i] & 0xFF;
        g = lpBitsColor[i + 1] & 0xFF;
        r = lpBitsColor[i + 2] & 0xFF;
        a = 0xFF - lpBitsMask[i] & 0xFF;
        argb = (a << 24) | (r << 16) | (g << 8) | b;
        image.setRGB(x, y, argb);
        x = (x + 1) % width;
        if (x == 0)
            y--;
    }
    User32.INSTANCE.ReleaseDC(null, hDC);
    return image;
}
Example 5
Project: yajsw-maven-master  File: WindowsXPMouse.java View source code
public LRESULT callback(int nCode, WPARAM wParam, MOUSEHOOKSTRUCT info) {
    LRESULT result = USER32INST.CallNextHookEx(hhk, nCode, wParam, info.getPointer());
    if (nCode >= 0) {
        int action = wParam.intValue();
        //System.out.println(action);
        switch(action) {
            case WM_LBUTTONDOWN:
                // do stuff
                break;
            case WM_RBUTTONDOWN:
                WindowsXPMouse.action.run();
                break;
            case WM_MBUTTONDOWN:
                //do other stuff
                break;
            case WM_LBUTTONUP:
                WindowsXPMouse.action.run();
                break;
            case WM_MOUSEMOVE:
                break;
            default:
                break;
        }
        /****************************DO NOT CHANGE, this code unhooks mouse *********************************/
        if (threadFinish == true) {
            //System.out.println("post quit");
            USER32INST.PostQuitMessage(0);
        }
    /***************************END OF UNCHANGABLE *******************************************************/
    }
    return result;
}
Example 6
Project: spark-svn-mirror-master  File: UserIdlePlugin.java View source code
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());
}
Example 7
Project: vlcj-master  File: Win32FullScreenHandler.java View source code
/**
     * Set the full-screen state of the window.
     *
     * @param fullScreen <code>true</code> to set full-screen; <code>false</code> to exit full-screen
     */
void setFullScreen(boolean fullScreen) {
    HWND hWnd = getHWND(Native.getComponentID(window));
    if (fullScreen) {
        windowState = getWindowState(hWnd);
        ExtendedUser32.INSTANCE.SetWindowLong(hWnd, GWL_STYLE, windowState.getStyle() & ~(WS_CAPTION | WS_THICKFRAME));
        ExtendedUser32.INSTANCE.SetWindowLong(hWnd, GWL_EXSTYLE, windowState.getExStyle() & ~(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE));
        MONITORINFO monitorInfo = getMonitorInfo(hWnd);
        RECT rect = monitorInfo.rcMonitor;
        ExtendedUser32.INSTANCE.SetWindowPos(hWnd, null, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
    } else {
        ExtendedUser32.INSTANCE.SetWindowLong(hWnd, GWL_STYLE, windowState.getStyle());
        ExtendedUser32.INSTANCE.SetWindowLong(hWnd, GWL_EXSTYLE, windowState.getExStyle());
        ExtendedUser32.INSTANCE.SetWindowPos(hWnd, null, windowState.getLeft(), windowState.getTop(), windowState.getRight() - windowState.getLeft(), windowState.getBottom() - windowState.getTop(), SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
        if (windowState.getMaximized()) {
            ExtendedUser32.INSTANCE.SendMessage(hWnd, User32.WM_SYSCOMMAND, new WPARAM(WinUser.SC_MAXIMIZE), new LPARAM(0));
        }
    }
}
Example 8
Project: synthuse-src-master  File: WindowsCommands.java View source code
public boolean cmdSelectMenu(String[] args) {
    if (!checkArgumentLength(args, 1))
        return false;
    WinPtr handle = findHandleWithXpath(args[0]);
    if (handle.isEmpty())
        return false;
    int id = findMenuIdWithXpath(args[0]);
    handle.convertToNativeHwnd();
    //LRESULT result = 
    //System.out.println("PostMessage to " + handle.hWndStr + " for id " + id);
    api.user32.PostMessage(handle.hWnd, Api.WM_COMMAND, new WPARAM(id), new LPARAM(0));
    //api.user32.SendMessage(handle.hWnd, Api.WM_COMMAND, new WPARAM(id), new LPARAM(0));
    return true;
}
Example 9
Project: nanobot-master  File: BlueStacksWinPlatform.java View source code
@Override
protected void doKeyPress(final int keyCode, final boolean shifted) throws InterruptedException {
    logger.log(Level.FINER, "doKeyPress " + keyCode + " " + shifted);
    while (isCtrlKeyDown()) {
        Thread.sleep(100);
    }
    final int lParam = 0x00000001 | 0x50 << /* scancode */
    16 | 0x01000000;
    final WPARAM wparam = new WinDef.WPARAM(keyCode);
    final WPARAM wparamShift = new WinDef.WPARAM(KeyEvent.VK_SHIFT);
    final LPARAM lparamDown = new WinDef.LPARAM(lParam);
    final LPARAM lparamUp = new WinDef.LPARAM(lParam | 1 << 30 | 1 << 31);
    if (shifted) {
        User32.INSTANCE.PostMessage(handler, WM_KEYDOWN, wparamShift, lparamDown);
    }
    User32.INSTANCE.PostMessage(handler, WM_KEYDOWN, wparam, lparamDown);
    User32.INSTANCE.PostMessage(handler, WM_KEYUP, wparam, lparamUp);
    if (shifted) {
        User32.INSTANCE.PostMessage(handler, WM_KEYUP, wparamShift, lparamUp);
    }
}
Example 10
Project: JAutoItX-master  File: TreeView.java View source code
/**
	 * 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;
}
Example 11
Project: yajsw-maven-mk2-master  File: WindowsXPMouse.java View source code
public LRESULT callback(int nCode, WPARAM wParam, MOUSEHOOKSTRUCT info) {
    LRESULT result = USER32INST.CallNextHookEx(hhk, nCode, wParam, info.getPointer());
    if (nCode >= 0) {
        int action = wParam.intValue();
        //System.out.println(action);
        switch(action) {
            case WM_LBUTTONDOWN:
                // do stuff
                break;
            case WM_RBUTTONDOWN:
                WindowsXPMouse.action.run();
                break;
            case WM_MBUTTONDOWN:
                //do other stuff
                break;
            case WM_LBUTTONUP:
                WindowsXPMouse.action.run();
                break;
            case WM_MOUSEMOVE:
                break;
            default:
                break;
        }
        /****************************DO NOT CHANGE, this code unhooks mouse *********************************/
        if (threadFinish == true) {
            //System.out.println("post quit");
            USER32INST.PostQuitMessage(0);
        }
    /***************************END OF UNCHANGABLE *******************************************************/
    }
    return result;
}