Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikachu2333 authored Jul 25, 2024
1 parent c30a245 commit b979817
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "SC_Starter"
version = "1.5.0"
version = "1.6.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion res/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Ctrl+Alt=O
# 第一行:控制截屏
# 第二行:从剪贴板中的图像钉到屏幕
# 第三行:退出软件
# 第四行:打开配置文件所在文件夹
# 第四行:打开配置文件
#
#
# ③格式如下:
Expand Down
16 changes: 10 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn set_hotkeys(
) -> JoinHandle<()> {
//根据配置文件设置快捷键
//因为检测的延迟性,至少要多出1s以免注册失败
thread::sleep(time::Duration::from_secs(3));
thread::sleep(time::Duration::from_secs(2));
let exe_path = exe_path.clone();
let conf_path = conf_path.clone();
let key_groups = key_groups.clone();
Expand Down Expand Up @@ -256,10 +256,14 @@ fn get_time(config_dir: &PathBuf) -> PathBuf {
Err(_) => String::from("0"),
};
let time_check_file = config_dir.join(&seconds);
match fs::File::create(&time_check_file) {
Ok(_) => true,
Err(_) => false,
};
if !time_check_file.exists() {
match fs::File::create(&time_check_file) {
Ok(_) => true,
Err(_) => panic!("No permissions."),
};
} else {
exit(-1);
}

let mut time_file_nums: Vec<u64> = Vec::new();
for entry in fs::read_dir(config_dir).unwrap() {
Expand Down Expand Up @@ -289,7 +293,7 @@ fn avoid_multiple(check_file: &PathBuf) -> JoinHandle<()> {
let file_path = check_file.clone();
let handle = thread::spawn(move || loop {
if file_path.exists() {
thread::sleep(time::Duration::from_secs(2))
thread::sleep(time::Duration::from_secs(1))
} else {
exit(-1);
}
Expand Down

0 comments on commit b979817

Please sign in to comment.