Skip to content

Commit

Permalink
Bug Fix 🐛
Browse files Browse the repository at this point in the history
	modified:   Cargo.lock
	modified:   Cargo.toml
	modified:   README.md
	modified:   src/lib.rs
	modified:   src/window.rs
	modified:   windows-capture-python/Cargo.lock
	modified:   windows-capture-python/Cargo.toml
	modified:   windows-capture-python/pyproject.toml
  • Loading branch information
NiiightmareXD committed Nov 26, 2023
1 parent 62b3eb0 commit a849ad6
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 🔥"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//!
//! ```toml
//! [dependencies]
//! windows-capture = "1.0.39"
//! windows-capture = "1.0.41"
//! ```
//! or run this command
//!
Expand Down
15 changes: 12 additions & 3 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,26 @@ impl Window {

/// Get Window Title
pub fn title(&self) -> Result<String, Box<dyn Error + Send + Sync>> {
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 {
return Ok(String::new());
}
}

Ok(String::from_utf16_lossy(&name))
let name = String::from_utf16(
&name
.as_slice()
.iter()
.take_while(|ch| **ch != 0x0000)
.copied()
.collect::<Vec<_>>(),
)?;

Ok(name)
}

/// Check If The Window Is A Valid Window
Expand Down
2 changes: 1 addition & 1 deletion windows-capture-python/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion windows-capture-python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 🔥"
Expand Down
2 changes: 1 addition & 1 deletion windows-capture-python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit a849ad6

Please sign in to comment.