You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when i use function of get_text(),it makes error: Err(Unknown { .. } - "Unknown error while interacting with the clipboard: failed to read clipboard string") . this error offen happen. could you resolve it?
my code:
`
pub fn get_selected_text_by_clipboard() -> Result<String, Box> {
use arboard::Clipboard;
use std::{thread, time::Duration};
let old_clipboard = (Clipboard::new()?.get_text(), Clipboard::new()?.get_image());
let mut write_clipboard = Clipboard::new()?;
let not_selected_placeholder = "";
write_clipboard.set_text(not_selected_placeholder)?;
thread::sleep(Duration::from_millis(50));
copy();
thread::sleep(Duration::from_millis(100));
let new_text = Clipboard::new()?.get_text();
println!("new_text: {:?}", new_text);
match old_clipboard {
(Ok(old_text), _) => {
// Old Content is Text
write_clipboard.set_text(old_text.clone())?;
if let Ok(new) = new_text {
if new.trim() == not_selected_placeholder.trim() {
Ok(String::new())
} else {
Ok(new)
}
} else {
Ok(String::new())
}
}
(_, Ok(image)) => {
// Old Content is Image
write_clipboard.set_image(image)?;
if let Ok(new) = new_text {
if new.trim() == not_selected_placeholder.trim() {
Ok(String::new())
} else {
Ok(new)
}
} else {
Ok(String::new())
}
}
_ => {
// Old Content is Empty
write_clipboard.clear()?;
if let Ok(new) = new_text {
if new.trim() == not_selected_placeholder.trim() {
Ok(String::new())
} else {
Ok(new)
}
} else {
Ok(String::new())
}
}
}
}
`
The text was updated successfully, but these errors were encountered:
Hi @letscubo. Can I first ask what version of Windows you are on and if you have any non-default locales/text encoding setup? (this shouldn't be an issue but I'd like to confirm) If this is still failing for you I can open a branch with more debug logging if you'd like to try that, which may show more specific details about the error from the system.
Additionally, do you know which of your get_text calls are failing?
when i use function of get_text(),it makes error:
Err(Unknown { .. } - "Unknown error while interacting with the clipboard: failed to read clipboard string")
. this error offen happen. could you resolve it?my code:
`
pub fn get_selected_text_by_clipboard() -> Result<String, Box> {
use arboard::Clipboard;
use std::{thread, time::Duration};
}
`
The text was updated successfully, but these errors were encountered: