use usehid_core::AgentHID;
use std::thread::sleep;
use std::time::Duration;
fn main() {
println!("📋 Copy & Paste Example");
println!("========================");
println!("Focus on a text editor in 3 seconds...");
sleep(Duration::from_secs(3));
let mut agent = AgentHID::new();
println!("📝 Typing text...");
agent.execute_json(r#"{"action": "type", "text": "Hello, this text will be copied!"}"#);
sleep(Duration::from_millis(300));
println!("🔤 Selecting all (Ctrl/Cmd+A)...");
#[cfg(target_os = "macos")]
agent.execute_json(r#"{"action": "key_combo", "modifiers": ["cmd"], "key": "a"}"#);
#[cfg(not(target_os = "macos"))]
agent.execute_json(r#"{"action": "key_combo", "modifiers": ["ctrl"], "key": "a"}"#);
sleep(Duration::from_millis(200));
println!("📋 Copying (Ctrl/Cmd+C)...");
#[cfg(target_os = "macos")]
agent.execute_json(r#"{"action": "key_combo", "modifiers": ["cmd"], "key": "c"}"#);
#[cfg(not(target_os = "macos"))]
agent.execute_json(r#"{"action": "key_combo", "modifiers": ["ctrl"], "key": "c"}"#);
sleep(Duration::from_millis(200));
println!("➡️ Moving to end...");
agent.execute_json(r#"{"action": "key_press", "key": "end"}"#);
sleep(Duration::from_millis(100));
agent.execute_json(r#"{"action": "key_press", "key": "enter"}"#);
agent.execute_json(r#"{"action": "key_press", "key": "enter"}"#);
sleep(Duration::from_millis(100));
println!("📄 Pasting (Ctrl/Cmd+V)...");
#[cfg(target_os = "macos")]
agent.execute_json(r#"{"action": "key_combo", "modifiers": ["cmd"], "key": "v"}"#);
#[cfg(not(target_os = "macos"))]
agent.execute_json(r#"{"action": "key_combo", "modifiers": ["ctrl"], "key": "v"}"#);
println!("\n✅ Text copied and pasted!");
}