use usehid_core::AgentHID;
use std::thread::sleep;
use std::time::Duration;
fn main() {
println!("📁 File Operations Example");
println!("==========================");
println!("Focus on a text editor (VS Code, Notepad, etc.) in 3 seconds...");
sleep(Duration::from_secs(3));
let mut agent = AgentHID::new();
println!("📄 Creating new file (Ctrl/Cmd+N)...");
#[cfg(target_os = "macos")]
agent.execute_json(r#"{"action": "key_combo", "modifiers": ["cmd"], "key": "n"}"#);
#[cfg(not(target_os = "macos"))]
agent.execute_json(r#"{"action": "key_combo", "modifiers": ["ctrl"], "key": "n"}"#);
sleep(Duration::from_millis(500));
println!("📝 Writing content...");
agent.execute_json(r#"{"action": "type", "text": "My Document - This is auto-generated content."}"#);
sleep(Duration::from_millis(300));
println!("💾 Saving file (Ctrl/Cmd+S)...");
#[cfg(target_os = "macos")]
agent.execute_json(r#"{"action": "key_combo", "modifiers": ["cmd"], "key": "s"}"#);
#[cfg(not(target_os = "macos"))]
agent.execute_json(r#"{"action": "key_combo", "modifiers": ["ctrl"], "key": "s"}"#);
sleep(Duration::from_millis(500));
println!("📝 Typing filename...");
agent.execute_json(r#"{"action": "type", "text": "my_document.md"}"#);
sleep(Duration::from_millis(200));
agent.execute_json(r#"{"action": "key_press", "key": "enter"}"#);
println!("\n✅ File saved!");
sleep(Duration::from_secs(1));
println!("\n📂 Opening file dialog (Ctrl/Cmd+O)...");
#[cfg(target_os = "macos")]
agent.execute_json(r#"{"action": "key_combo", "modifiers": ["cmd"], "key": "o"}"#);
#[cfg(not(target_os = "macos"))]
agent.execute_json(r#"{"action": "key_combo", "modifiers": ["ctrl"], "key": "o"}"#);
println!("📂 File dialog opened!");
}