diff --git a/src/tools/window.rs b/src/tools/window.rs index 556a830..9ac8848 100644 --- a/src/tools/window.rs +++ b/src/tools/window.rs @@ -19,7 +19,7 @@ use objc::{msg_send, sel, sel_impl}; #[cfg(target_os = "windows")] use windows::Win32::Foundation::{HWND, RECT}; #[cfg(target_os = "windows")] -use windows::Win32::UI::WindowsAndMessaging::{GetWindowRect, GetWindowText, GetWindowTextLengthW}; +use windows::Win32::UI::WindowsAndMessaging::{GetWindowRect, GetWindowTextW, GetWindowTextLengthW}; #[cfg(target_os = "linux")] use x11::xlib; diff --git a/src/utils/platform.rs b/src/utils/platform.rs index a2b1d78..1ddb34d 100644 --- a/src/utils/platform.rs +++ b/src/utils/platform.rs @@ -13,7 +13,7 @@ struct EnumData { #[cfg(target_os = "windows")] pub fn get_window_by_pid(pid: u32) -> Result> { - use windows::Win32::Foundation::HWND; + use windows::Win32::Foundation::LPARAM; use windows::Win32::UI::WindowsAndMessaging::EnumWindows; use std::sync::Mutex; @@ -25,8 +25,8 @@ pub fn get_window_by_pid(pid: u32) -> Result Result i32 { +unsafe extern "system" fn enum_window_callback(hwnd: windows::Win32::Foundation::HWND, lparam: windows::Win32::Foundation::LPARAM) -> windows::Win32::Foundation::BOOL { use std::sync::Mutex; use windows::Win32::UI::WindowsAndMessaging::GetWindowThreadProcessId; - let data = &*(lparam as *const Mutex); + let data = &*(lparam.0 as *const Mutex); let mut process_id = 0u32; GetWindowThreadProcessId(hwnd, Some(&mut process_id)); let mut enum_data = data.lock().unwrap(); if process_id == enum_data.target_pid { enum_data.window = Some(hwnd); - return 0; + return windows::Win32::Foundation::BOOL(0); } - 1 + windows::Win32::Foundation::BOOL(1) } #[cfg(target_os = "linux")]