Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS捕获所有窗口只捕获到了MenuBar #202

Open
yIllusionSky opened this issue Mar 2, 2025 · 2 comments
Open

MacOS捕获所有窗口只捕获到了MenuBar #202

yIllusionSky opened this issue Mar 2, 2025 · 2 comments

Comments

@yIllusionSky
Copy link

系统:Darwin
代码(参考示例):

use std::time::Instant;
use xcap::Window;

fn normalized(filename: &str) -> String {
    filename.replace(['|', '\\', ':', '/'], "")
}
#[test]
fn main() {
    let start = Instant::now();
    let windows = Window::all().unwrap();
    for window in windows {
        
        println!(
            "Window: {:?} {:?} {:?}",
            window.title().unwrap(),
            (
                window.x().unwrap(),
                window.y().unwrap(),
                window.width().unwrap(),
                window.height().unwrap()
            ),
            (
                window.is_minimized().unwrap(),
                window.is_maximized().unwrap()
            )
        );
        
    }

    println!("运行耗时: {:?}", start.elapsed());
}

输出:

Window: "Menubar" (0, 0, 1728, 37) (false, false)
运行耗时: 69.463125ms
@nashaofu
Copy link
Owner

nashaofu commented Mar 3, 2025

什么版本?有给程序授权截图权限吗

@yIllusionSky
Copy link
Author

什么版本?有给程序授权截图权限吗

解决了,权限问题,给了就好了,不过有没有什么函数能自动开启系统授权的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants