-
Notifications
You must be signed in to change notification settings - Fork 214
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
Question about how to list all running window app names [Code Review/Question] #535
Comments
It's simpler if I declare the Dict Key and Value so I don't need to mess with pointers, I am still not sure about the usage of #[warn(unused_imports)]
use core_foundation::base::{CFType, TCFType};
use core_foundation::dictionary::{CFDictionary, CFDictionaryRef};
use core_foundation::string::CFString;
use core_graphics::window::{copy_window_info, kCGNullWindowID, kCGWindowListOptionAll};
fn main() {
let windows_info = copy_window_info(kCGWindowListOptionAll, kCGNullWindowID).unwrap();
for window_info in windows_info.get_all_values() {
let key = CFString::from_static_string("kCGWindowName");
let winfo_hash: CFDictionary<CFString, CFType> =
unsafe { TCFType::wrap_under_get_rule(window_info as CFDictionaryRef) };
let window_name = winfo_hash
.get(key)
.downcast::<CFString>()
.unwrap()
.to_string();
println!("{:?}", window_name)
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm working with Rust and Core Foundations and I'd like to know if the code looks right or if it has some flaws or if I can make it simpler
Is that right? or do we have a "simpler" way of doing that? My goal is to take a screenshot of the window app if t matches some criteria
Thanks in advance.
The text was updated successfully, but these errors were encountered: