diff --git a/src/windows/mod.rs b/src/windows/mod.rs index eccf620..4b9d3c3 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -1,10 +1,13 @@ -use std::ptr::null_mut; -use std::sync::atomic::{AtomicPtr, Ordering}; +use std::{ + mem::MaybeUninit, + ptr::null_mut, + sync::atomic::{AtomicPtr, Ordering}, +}; use winapi::ctypes::c_int; use winapi::shared::minwindef::{DWORD, HINSTANCE, LPARAM, LRESULT, WPARAM}; -use winapi::shared::windef::HHOOK__; +use winapi::shared::windef::{HHOOK__, HWND}; use winapi::um::errhandlingapi::GetLastError; -use winapi::um::winuser::{SetWindowsHookExW, UnhookWindowsHookEx}; +use winapi::um::winuser::{GetMessageW, SetWindowsHookExW, UnhookWindowsHookEx, MSG}; pub mod keyboard; pub mod mouse; @@ -31,6 +34,9 @@ pub unsafe fn hook( return Err(error); } + let mut msg: MSG = MaybeUninit::zeroed().assume_init(); + GetMessageW(&mut msg, 0 as HWND, 0, 0); + Ok(()) } diff --git a/src/windows/mouse.rs b/src/windows/mouse.rs index c295ef0..bcf3d8b 100644 --- a/src/windows/mouse.rs +++ b/src/windows/mouse.rs @@ -209,13 +209,13 @@ impl Robot { _ => None, } } - // WM_MOUSEMOVE => { - // let (x, y) = Self::get_mouse_point(l_param); - // Some(EventType::MouseMoveTo { - // x: x as f64, - // y: y as f64, - // }) - // } + WM_MOUSEMOVE => { + let (x, y) = Self::get_mouse_point(l_param); + Some(EventType::MouseMoveTo { + x: x as f64, + y: y as f64, + }) + } _ => None, };