Java 类com.sun.jna.platform.win32.WinDef.LPARAM 实例源码

项目:nanobot    文件:BlueStacksWinPlatform.java   
@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 /* extended */;
    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);
    }
}
项目:NanoUI    文件:TaskBar.java   
@Override
public void dispose() {
    super.dispose();
    window.dispose(AppUI.getMainWindow());
    if (ENABLED_NOTIFICATIONS)
        TrayHook.INSTANCE.UnregisterSystemTrayHook();
    User32Ext.INSTANCE.SystemParametersInfo(SPI.SPI_SETWORKAREA, 0, old.getPointer(), 0);
    User32Ext.INSTANCE.DeregisterShellHookWindow(local);
    if (noExplorer) {
        backgroundWindow.getWindow().closeDisplay();
        User32.INSTANCE.PostThreadMessage(keysThreadID, WM_QUIT, new WPARAM(), new LPARAM());
        User32Ext.INSTANCE.SystemParametersInfo(SPI.SPI_SETMINIMIZEDMETRICS, oldMM.size(), oldMM.getPointer(), 0);
    } else {
        if (taskbar != null)
            User32.INSTANCE.ShowWindow(taskbar, SW_SHOW);
    }
}
项目:synthuse-src    文件:WindowsCommands.java   
public boolean cmdSendCommandMsg(String[] args) {
    if (!checkArgumentLength(args, 3))
        return false;
    WinPtr handle = findHandleWithXpath(args[0]); //xpath to HWND is first argument
    if (handle.isEmpty())
        return false;
    int id = Integer.parseInt(args[1]); //context menu id is supplied as second argument
    int idLparam = Integer.parseInt(args[2]); //context menu id is supplied as second argument
    handle.convertToNativeHwnd();
    //LRESULT result = 
    //System.out.println("Send Message  WM_COMMAND to " + handle.toString() + " PARAMS: " + id + ", " + idLparam);
    //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(idLparam));

    return true;
}
项目:synthuse-src    文件:WindowsCommands.java   
public boolean cmdSendMessage(String[] args) {
    if (!checkArgumentLength(args, 4))
        return false;
    WinPtr handle = findHandleWithXpath(args[0]); //xpath to HWND is first argument
    if (handle.isEmpty())
        return false;
    int msg = Integer.parseInt(args[1]);
    int id = Integer.parseInt(args[2]); //context menu id is supplied as second argument
    int idLparam = Integer.parseInt(args[3]); //context menu id is supplied as second argument
    handle.convertToNativeHwnd();
    //LRESULT result = 
    //System.out.println("Send Message  WM_COMMAND to " + handle.toString() + " PARAMS: " + id + ", " + idLparam);
    //api.user32.PostMessage(handle.hWnd, Api.WM_COMMAND, new WPARAM(id), new LPARAM(0));
    api.user32.SendMessage(handle.hWnd, msg, new WPARAM(id), new LPARAM(idLparam));

    return true;
}
项目:MonitorBrightness    文件:MonitorInfoDemo.java   
/**
 * @param args (ignored)
 */
public static void main(String[] args)
{
    System.out.println("Installed Physical Monitors: " + User32.INSTANCE.GetSystemMetrics(WinUser.SM_CMONITORS));

    User32.INSTANCE.EnumDisplayMonitors(null, null, new MONITORENUMPROC() {

        @Override
        public int apply(HMONITOR hMonitor, HDC hdc, RECT rect, LPARAM lparam)
        {
            enumerate(hMonitor);

            return 1;
        }

    }, new LPARAM(0));
}
项目:jnaplatext    文件:CmdExeTyper.java   
/**
 * Writes text to cmd.exe.
 *
 * @param text The text to write to cmd.exe.
 */
public final void write(final String text) {
    for (char c : text.toCharArray()) {
        /* Send the character to cmd.exe. */
        User32.INSTANCE.PostMessage(
            this.hwnd, WinUser.WM_CHAR,
            new WPARAM(c), new LPARAM(0));

        /* Normally cmd.exe won't need a WM_KEYUP, but if this is a
         * repeated series of characters (33, aaa, etc.) then
         * cmd.exe will ignore every character other than the first
         * one unless it gets a WM_KEYUP after each WM_CHAR. */
        short vkey = User32.INSTANCE.VkKeyScan(c);
        int oemScan = User32.INSTANCE.MapVirtualKey(
            vkey & 0xff, 0); /* MAPVK_VK_TO_VSC */
        User32.INSTANCE.PostMessage(
            this.hwnd, WinUser.WM_KEYUP,
            new WPARAM(vkey & 0xff),
            new LPARAM(0 | (oemScan << 16) | (3 << 31)));
    }
}
项目:NanoUI    文件:NotificationsWindow.java   
public void iconAdded(NOTIFYICONDATA data) {
    if (true)
        return;
    System.out.println("Added: " + data.uID);
    if (!iconsMap.containsKey(data.guidItem))
        iconsTask.add(() -> {
            NotificationButton btn = new NotificationButton(0, 0, 16, 16, "Test", data);
            btn.setOnButtonPress(() -> {
                User32Ext.INSTANCE.SendMessage(data.hWnd, WM_CONTEXTMENU,
                        new WPARAM(Pointer.nativeValue(data.hWnd.getPointer())), new LPARAM());
            });
            icons.addComponent(btn);
            iconsMap.put(data.guidItem, btn);
        });
}
项目:trezor-ssh-agent    文件:JNIMouseHook.java   
private LowLevelMouseProc hookTheMouse() {
    return new LowLevelMouseProc() {
        @Override
        public WinDef.LRESULT callback(int nCode, WinDef.WPARAM wParam, MSLLHOOKSTRUCT info) {
            if (nCode >= 0) {

                switch (wParam.intValue()) {
                    case JNIMouseHook.WM_LBUTTONDOWN:
                        addEventToQueue(info.pt.x, info.pt.y);
                        break;
                    case JNIMouseHook.WM_RBUTTONDOWN:
                        addEventToQueue(info.pt.x, info.pt.y);
                        break;
                    case JNIMouseHook.WM_MBUTTONDOWN:
                        addEventToQueue(info.pt.x, info.pt.y);
                        break;
                    case JNIMouseHook.WM_MOUSEMOVE:

                        break;
                    default:
                        break;
                }
                // unhook if needed
                if (threadFinish == true) {
                    USER32INST.PostQuitMessage(0);
                }
            }

            Pointer ptr = info.getPointer();
            long peer = Pointer.nativeValue(ptr);
            return USER32INST.CallNextHookEx(hhk, nCode, wParam, new LPARAM(peer));
        }
    };
}
项目:synthuse-src    文件:WindowsCommands.java   
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;
}
项目:synthuse-src    文件:WindowsCommands.java   
public boolean cmdSelectContextMenuId(String[] args) {
    if (!checkArgumentLength(args, 2))
        return false;
    WinPtr handle = findHandleWithXpath(args[0]); //xpath to HWND is first argument
    if (handle.isEmpty())
        return false;
    int id = Integer.parseInt(args[1]); //context menu id is supplied as second argument
    handle.convertToNativeHwnd();
    //LRESULT result = 
    System.out.println("PostMessage to " + handle.toString() + " for id " + id + " - " + Api.MAKELONG(id, 0));
    //api.user32.PostMessage(handle.hWnd, Api.WM_COMMAND, new WPARAM(id), new LPARAM(0));
    api.user32.SendMessage(handle.hWnd, Api.WM_COMMAND, new WPARAM(Api.MAKELONG(id, 0)), new LPARAM(0));

    return true;
}
项目:JAutoItX    文件:TreeView.java   
private static HWND getFirstItemHandle(final String title,
        final String text, final String control) {
    HWND firstItemHWND = null;
    HWND hWnd = Control.getHandle_(title, text, control);
    if (hWnd != null) {
        firstItemHWND = Win32.user32.SendMessage(hWnd, TVM_GETNEXTITEM,
                new WPARAM(TVGN_ROOT), new LPARAM(0));
    }
    return firstItemHWND;
}
项目:twitchplayclient    文件:TreeView.java   
private static HWND getFirstItemHandle(final String title,
        final String text, final String control) {
    HWND firstItemHWND = null;
    HWND hWnd = Control.getHandle_(title, text, control);
    if (hWnd != null) {
        firstItemHWND = Win32.user32.SendMessage(hWnd, TVM_GETNEXTITEM,
                new WPARAM(TVGN_ROOT), new LPARAM(0));
    }
    return firstItemHWND;
}
项目:MonitorBrightness    文件:MonitorControllerJna.java   
public MonitorControllerJna()
{
    System.out.println("Monitors: " + User32.INSTANCE.GetSystemMetrics(User32.SM_CMONITORS));

    User32.INSTANCE.EnumDisplayMonitors(null, null, new MONITORENUMPROC() {

        @Override
        public int apply(HMONITOR hMonitor, HDC hdc, RECT rect, LPARAM lparam)
        {
            System.out.println("Monitor handle: " + hMonitor);

            MONITORINFOEX info = new MONITORINFOEX();
            User32.INSTANCE.GetMonitorInfo(hMonitor, info);
            System.out.println(info.rcMonitor);

            DWORDByReference pdwNumberOfPhysicalMonitors = new DWORDByReference();
            Dxva2.INSTANCE.GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, pdwNumberOfPhysicalMonitors);
            int monitorCount = pdwNumberOfPhysicalMonitors.getValue().intValue();

            System.out.println("Physical monitors for " + hMonitor + ": " + monitorCount);

            PHYSICAL_MONITOR[] physMons = new PHYSICAL_MONITOR[monitorCount];
            Dxva2.INSTANCE.GetPhysicalMonitorsFromHMONITOR(hMonitor, monitorCount, physMons);

            for (PHYSICAL_MONITOR mon : physMons)
            {
                String desc = new String(mon.szPhysicalMonitorDescription);
                monitors.add(new MonitorJna(mon.hPhysicalMonitor, desc));
            }

            return 1;
        }
    }, new LPARAM(0));
}
项目:NanoUI    文件:Macros.java   
public static int GET_X_LPARAM(LPARAM lParam) {
    return (int) lParam.longValue() & 0xFFFF;
}
项目:NanoUI    文件:Macros.java   
public static int GET_Y_LPARAM(LPARAM lParam) {
    return (int) (lParam.longValue() >> 16);
}
项目:NanoUI    文件:ContextWindow.java   
@Override
public void update(float delta) {
    compWin.update(delta, window);
    if (run) {
        compWin.dispose(window);
        Container bottomBtns = new Container(0, 0, 200, 60);

        char[] name = new char[1024];
        User32Ext.INSTANCE.GetWindowTextW(hwndWin, name, name.length);
        String title = Native.toString(name);

        Button btnClose = new Button(0, 0, 200, 30, "Close");
        btnClose.setPreicon(Theme.ICON_CHROME_CLOSE);
        btnClose.setPreiconSize(12);
        btnClose.setOnButtonPress(() -> {
            User32.INSTANCE.PostMessage(this.hwndWin, WM_CLOSE, new WPARAM(), new LPARAM());
            TaskManager.addTask(() -> window.setVisible(false));
        });
        Button btnOpen = new Button(0, 30, 200, 30, title);
        btnOpen.setOnButtonPress(() -> {
            char[] classNameC = new char[128];
            User32.INSTANCE.GetClassName(hwndWin, classNameC, classNameC.length);
            String className = Native.toString(classNameC);
            if (!className.equals("ApplicationFrameWindow"))
                try {
                    new ProcessBuilder(WindowUtils.getProcessFilePath(hwndWin), "").start();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            TaskManager.addTask(() -> window.setVisible(false));
        });
        bottomBtns.addComponent(btnClose);
        bottomBtns.addComponent(btnOpen);

        Image icon = new Image(13, 38, 16, 16, Util.getIcon(hwndWin, window), true);
        bottomBtns.addComponent(icon);
        compWin.addComponent(bottomBtns);

        Container tasks = new Container(-20, 0, 220, 140);
        tasks.setLayout(new FlowLayout(Direction.DOWN, 0, 10));
        for (int i = 0; i < 4; i++) {
            Button t = new Button(0, 0, 220, 30, "Task " + i);
            t.setWindowAlignment(Alignment.LEFT_TOP);
            t.setAlignment(Alignment.RIGHT_BOTTOM);
            tasks.addComponent(t);
        }
        compWin.addComponent(tasks);
        TaskManager.addTask(() -> window.setVisible(true));
        run = false;
    }

}
项目:DigitalMediaServer    文件:ProcessManager.java   
/**
 * Sends {@code WM_CLOSE} to the specified Windows {@link Process}.
 *
 * @param processInfo the {@link ProcessInfo} referencing the
 *            {@link Process} to send to.
 * @return {@code true} if {@code WM_CLOSE} was sent, {@code false}
 *         otherwise.
 */
protected boolean stopWindowsProcessWMClosed(@Nonnull ProcessInfo processInfo) {
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace(
            "Attempting to stop timed out process \"{}\" ({}) with WM_CLOSE",
            processInfo.getName(),
            processInfo.getPID()
        );
    }
    HANDLE hProc = Kernel32.INSTANCE.OpenProcess(
        Kernel32.SYNCHRONIZE | Kernel32.PROCESS_TERMINATE,
        false,
        processInfo.getPID()
    );
    if (hProc == null) {
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace(
                "Failed to get Windows handle for process \"{}\" ({}) during WM_CLOSE",
                processInfo.getName(),
                processInfo.getPID()
            );
        }
        return false;
    }
    final Memory posted = new Memory(1);
    posted.setByte(0, (byte) 0);
    Memory dwPID = new Memory(4);
    dwPID.setInt(0, processInfo.getPID());
    User32.INSTANCE.EnumWindows(new WNDENUMPROC() {

        @Override
        public boolean callback(HWND hWnd, Pointer data) {
            IntByReference dwID = new IntByReference();
            User32.INSTANCE.GetWindowThreadProcessId(hWnd, dwID);

            if (dwID.getValue() == data.getInt(0)) {
                User32.INSTANCE.PostMessage(hWnd, User32.WM_CLOSE, new WPARAM(0), new LPARAM(0));
                posted.setByte(0, (byte) 1);
            }
            return true;
        }
    }, dwPID);
    Kernel32.INSTANCE.CloseHandle(hProc);
    if (LOGGER.isTraceEnabled()) {
        if (posted.getByte(0) > 0) {
            LOGGER.trace(
                "WM_CLOSE sent to process \"{}\" ({}) with PostMessage",
                processInfo.getName(),
                processInfo.getPID()
            );
        } else {
            LOGGER.trace(
                "Can't find any Windows belonging to process \"{}\" ({}), unable to send WM_CLOSE",
                processInfo.getName(),
                processInfo.getPID()
            );
        }
    }
    return posted.getByte(0) > 0;
}
项目:MercuryTrade    文件:MainTestKeyHook.java   
public LRESULT callback(int nCode, WPARAM wParam, LPARAM lParam) {
    System.err.println("callback bbbnhkilhjkibh nCode: " + nCode);
    return new LRESULT(0);
}
项目:jpexs-decompiler    文件:WinUser.java   
/**
 * @param hwnd [in] Type: HWND
 *
 * A handle to the window.
 *
 * @param uMsg [in] Type: UINT
 *
 * The message.
 *
 * For lists of the system-provided messages, see System-Defined
 * Messages.
 *
 * @param wParam [in] Type: WPARAM
 *
 * Additional message information. The contents of this parameter depend
 * on the value of the uMsg parameter.
 *
 * @param lParam [in] Type: LPARAM
 *
 * Additional message information. The contents of this parameter depend
 * on the value of the uMsg parameter.
 *
 * @return the lresult
 */
LRESULT callback(HWND hwnd, int uMsg, WPARAM wParam, LPARAM lParam);
项目:jnaplatext    文件:WinUser.java   
/**
 * An application-defined function that processes messages sent
 * to a window.
 *
 * @param hwnd A handle to the window.
 * @param uMsg The message.
 * @param wParam Additional message information.
 * @param lParam Additional message information.
 * @return The result of the message processing and depends on
 * the message sent
 */
LRESULT callback(HWND hwnd, int uMsg, WPARAM wParam, LPARAM lParam);
项目:Nird2    文件:WindowsShutdownManagerImpl.java   
LRESULT DefWindowProc(HWND hwnd, int msg, WPARAM wp, LPARAM lp);
项目:Nird2    文件:WindowsShutdownManagerImpl.java   
LRESULT callback(HWND hwnd, int msg, WPARAM wp, LPARAM lp);
项目:Nird2    文件:WindowsShutdownManagerImpl.java   
LRESULT DefWindowProc(HWND hwnd, int msg, WPARAM wp, LPARAM lp);
项目:Nird2    文件:WindowsShutdownManagerImpl.java   
LRESULT callback(HWND hwnd, int msg, WPARAM wp, LPARAM lp);
项目:Clipcon-Client    文件:User32X.java   
void SendMessage(HWND nextViewer, int uMsg, WPARAM wParam, LPARAM lParam);
项目:NanoUI    文件:User32Ext.java   
public LRESULT SendMessage(HWND hwnd, int msg, WPARAM wParam, LPARAM lParam);
项目:NanoUI    文件:User32Ext.java   
public boolean SendNotifyMessage(HWND hwnd, int msg, WPARAM wParam, LPARAM lParam);
项目:briar    文件:WindowsShutdownManagerImpl.java   
LRESULT DefWindowProc(HWND hwnd, int msg, WPARAM wp, LPARAM lp);
项目:briar    文件:WindowsShutdownManagerImpl.java   
public LRESULT callback(HWND hwnd, int msg, WPARAM wp, LPARAM lp);