libobs_window_helper/
lib.rs1#[cfg(not(windows))]
7compile_error!("This library only supports windows!");
8
9#[cfg(not(target_pointer_width = "64"))]
10compile_error!("compilation is only allowed for 64-bit targets");
11
12mod game;
13mod monitor;
14mod util;
15mod window;
16
17pub use util::*;
18#[cfg(test)]
19mod test;
20
21pub use game::*;
22pub use helper::*;
23use win_iterator::{first_window, next_window};
24use windows::Win32::{Foundation::HWND, System::Console::GetConsoleWindow};
25
26pub fn get_all_windows(mode: WindowSearchMode) -> anyhow::Result<Vec<WindowInfo>> {
37 let mut use_find_window_ex = false;
38
39 let mut parent = None as Option<HWND>;
40 let window = unsafe { first_window(mode, &mut parent, &mut use_find_window_ex)? };
41 let mut window = Some(window);
42
43 let curr = unsafe { GetConsoleWindow() };
44
45 let mut out = Vec::new();
46 while window.is_some_and(|e| !e.is_invalid()) {
47 let w = window.unwrap();
48 if curr != w {
49 let res = get_window_info(w);
50 if let Ok(info) = res {
51 out.push(info);
52 } else {
53 }
55 }
56
57 unsafe {
58 window = next_window(window, mode, &mut parent, use_find_window_ex)?;
59 }
60 }
61
62 Ok(out)
63}