Skip to content

Commit a95f86e

Browse files
committed
fix sleep
Signed-off-by: bootjp / Yoshiaki Ueda <[email protected]>
1 parent dea6814 commit a95f86e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/server/handler.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
use std::time::Duration;
12
use anyhow::{anyhow, Result};
23
use axum::Json;
34
use clipboard_win::set_clipboard_string;
45
use serde::{Deserialize, Serialize};
6+
use tokio::time::sleep;
57

68
use crate::win32api::{input, window};
79

@@ -18,6 +20,7 @@ pub struct UrlResponse {
1820
}
1921

2022
pub async fn url(Json(payload): Json<UrlRequest>) -> Result<Json<UrlResponse>, ApiError> {
23+
const INPUT_WAIT_DURATION: Duration = Duration::from_millis(500);
2124
let url = &payload.url;
2225
println!("received url: {url}");
2326

@@ -26,9 +29,11 @@ pub async fn url(Json(payload): Json<UrlRequest>) -> Result<Json<UrlResponse>, A
2629
let hwnd = window::find_window_by_name("VRChat");
2730
window::set_foreground_window(hwnd)?;
2831

32+
sleep(INPUT_WAIT_DURATION).await;
2933
input::send_dummy_input()?;
3034
window::set_foreground_window(hwnd)?;
3135

36+
sleep(INPUT_WAIT_DURATION).await;
3237
input::send_paste_input().await?;
3338
input::send_enter_input()?;
3439

src/win32api/input.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ pub fn send_dummy_input() -> Result<()> {
5050
pub async fn send_paste_input() -> Result<()> {
5151
const ERROR_MESSAGE: &str = "failed to send `Paste` (`Ctrl` + `V`) input";
5252
const DURATION: Duration = Duration::from_millis(100);
53-
const INPUT_WAIT_DURATION: Duration = Duration::from_millis(500);
54-
55-
sleep(INPUT_WAIT_DURATION).await;
5653

5754
let inputs = [
5855
// Left Ctrl Down

0 commit comments

Comments
 (0)