rust防锁屏

use rsautogui::mouse;
use std::thread::sleep;
use std::time::Duration;
use anyhow::{self, Ok};

fn run(x: u16) ->Result<(), anyhow::Error>{
    let timeseconds = Duration::from_secs(5);
    mouse::move_to(x, 500);
    sleep(timeseconds);
    Ok(())
}

fn main() {
    let mut x: i8 = -1;
    loop {
        if x > 0{
            run(100_u16).unwrap_or_else(|_|{});
        }else{
            run(300_u16).unwrap_or_else(|_|{});
        }
        x = -x ;
    }
    
}

  

posted @ 2023-10-16 10:47  CrossPython  阅读(48)  评论(0编辑  收藏  举报