20 fixes: mutex poisoning recovery, clickthrough shutdown, audio cleanup, config corruption, GIF aspect ratio, ffmpeg crash detection, cancel export, discard confirm, thumbnail cache, keyboard nav, right-click tracking, multi-monitor overlay, click injection fix, update script robustness, effect cleanup, concat guard, dead code removal
This commit is contained in:
+34
-14
@@ -5,11 +5,19 @@ use std::time::{Duration, Instant};
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize)]
|
||||
pub enum MouseButton {
|
||||
Left,
|
||||
Right,
|
||||
Middle,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize)]
|
||||
pub struct Click {
|
||||
pub time_secs: f64,
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub button: MouseButton,
|
||||
}
|
||||
|
||||
pub struct ClickRecorder {
|
||||
@@ -30,26 +38,38 @@ pub fn start() -> ClickRecorder {
|
||||
use windows::Win32::UI::WindowsAndMessaging::GetCursorPos;
|
||||
|
||||
const VK_LBUTTON: i32 = 0x01;
|
||||
const VK_RBUTTON: i32 = 0x02;
|
||||
const VK_MBUTTON: i32 = 0x04;
|
||||
|
||||
let buttons = [
|
||||
(VK_LBUTTON, MouseButton::Left),
|
||||
(VK_RBUTTON, MouseButton::Right),
|
||||
(VK_MBUTTON, MouseButton::Middle),
|
||||
];
|
||||
|
||||
let start = Instant::now();
|
||||
let mut last_pressed = false;
|
||||
let mut last_pressed = [false; 3];
|
||||
|
||||
while running_clone.load(Ordering::Relaxed) {
|
||||
let state = unsafe { GetAsyncKeyState(VK_LBUTTON) };
|
||||
let pressed = (state as u16 & 0x8000) != 0;
|
||||
if pressed && !last_pressed {
|
||||
let mut pt = POINT::default();
|
||||
if unsafe { GetCursorPos(&mut pt) }.is_ok() {
|
||||
let click = Click {
|
||||
time_secs: start.elapsed().as_secs_f64(),
|
||||
x: pt.x,
|
||||
y: pt.y,
|
||||
};
|
||||
if let Ok(mut v) = clicks_clone.lock() {
|
||||
v.push(click);
|
||||
for (i, &(vk, button)) in buttons.iter().enumerate() {
|
||||
let state = unsafe { GetAsyncKeyState(vk) };
|
||||
let pressed = (state as u16 & 0x8000) != 0;
|
||||
if pressed && !last_pressed[i] {
|
||||
let mut pt = POINT::default();
|
||||
if unsafe { GetCursorPos(&mut pt) }.is_ok() {
|
||||
let click = Click {
|
||||
time_secs: start.elapsed().as_secs_f64(),
|
||||
x: pt.x,
|
||||
y: pt.y,
|
||||
button,
|
||||
};
|
||||
if let Ok(mut v) = clicks_clone.lock() {
|
||||
v.push(click);
|
||||
}
|
||||
}
|
||||
}
|
||||
last_pressed[i] = pressed;
|
||||
}
|
||||
last_pressed = pressed;
|
||||
thread::sleep(Duration::from_millis(5));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user