获取所有 chrome windows

Get all chrome windows

我想得到所有 chrome windows 运行 当前。下面的代码将获取所有 windows.

final WinDef.HWND[] windowHandle = new WinDef.HWND[1];

    User32.INSTANCE.EnumWindows(new WinUser.WNDENUMPROC() {
        @Override
        public boolean callback(WinDef.HWND hwnd, Pointer pointer) {
            if (matches(hwnd)) {
                windowHandle[0] = hwnd;
                return false;
            }
            return true;
        }
    }, Pointer.NULL);

怎么只能得到运行chromewindows?

我认为使用像 Sigar 这样已经完成的第三方库会更好。 https://support.hyperic.com/display/SIGAR/Home

您将因处理流程而获得 API。 至少你可以看看源代码。

Sigar sigar = new Sigar();
ProcessFinder find = new ProcessFinder(sigar);
find.find("Exe.Name.ct=chrome");