diff --git a/Cargo.lock b/Cargo.lock index 18618a5..71b88b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -548,7 +548,7 @@ dependencies = [ [[package]] name = "windows-capture" -version = "1.0.39" +version = "1.0.41" dependencies = [ "image", "log", @@ -560,7 +560,7 @@ dependencies = [ [[package]] name = "windows-capture-python" -version = "1.0.39" +version = "1.0.41" dependencies = [ "pyo3", "windows", diff --git a/Cargo.toml b/Cargo.toml index ea05c07..62d609e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "windows-capture" -version = "1.0.39" +version = "1.0.41" authors = ["NiiightmareXD"] edition = "2021" description = "Fastest Windows Screen Capture Library For Rust 🔥" diff --git a/README.md b/README.md index 41953c0..5a58ccf 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Add this library to your `Cargo.toml`: ```toml [dependencies] -windows-capture = "1.0.39" +windows-capture = "1.0.41" ``` or run this command diff --git a/src/lib.rs b/src/lib.rs index a369fcc..8a8effc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,7 +22,7 @@ //! //! ```toml //! [dependencies] -//! windows-capture = "1.0.39" +//! windows-capture = "1.0.41" //! ``` //! or run this command //! diff --git a/src/window.rs b/src/window.rs index d590780..195168b 100644 --- a/src/window.rs +++ b/src/window.rs @@ -73,9 +73,9 @@ impl Window { /// Get Window Title pub fn title(&self) -> Result> { - let len = unsafe { GetWindowTextLengthW(self.window) } + 1; + let len = unsafe { GetWindowTextLengthW(self.window) }; - let mut name = vec![0u16; len as usize]; + let mut name = vec![0u16; len as usize + 1]; if len > 1 { let copied = unsafe { GetWindowTextW(self.window, &mut name) }; if copied == 0 { @@ -83,7 +83,16 @@ impl Window { } } - Ok(String::from_utf16_lossy(&name)) + let name = String::from_utf16( + &name + .as_slice() + .iter() + .take_while(|ch| **ch != 0x0000) + .copied() + .collect::>(), + )?; + + Ok(name) } /// Check If The Window Is A Valid Window diff --git a/windows-capture-python/Cargo.lock b/windows-capture-python/Cargo.lock index 247ad1c..2770193 100644 --- a/windows-capture-python/Cargo.lock +++ b/windows-capture-python/Cargo.lock @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.39" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ diff --git a/windows-capture-python/Cargo.toml b/windows-capture-python/Cargo.toml index c815d94..0c46ada 100644 --- a/windows-capture-python/Cargo.toml +++ b/windows-capture-python/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "windows-capture-python" -version = "1.0.39" +version = "1.0.41" authors = ["NiiightmareXD"] edition = "2021" description = "Fastest Windows Screen Capture Library For Python 🔥" diff --git a/windows-capture-python/pyproject.toml b/windows-capture-python/pyproject.toml index ae0ff52..3313fa6 100644 --- a/windows-capture-python/pyproject.toml +++ b/windows-capture-python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "windows-capture" -version = "1.0.39" +version = "1.0.41" description = "Fastest Windows Screen Capture Library For Python 🔥" readme = "README.md" requires-python = ">=3.9"