diff --git a/Cargo.lock b/Cargo.lock index ba23732..e9989ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,21 +30,21 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "indexmap" -version = "2.5.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "equivalent", "hashbrown", @@ -58,36 +58,36 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] [[package]] name = "serde" -version = "1.0.193" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", @@ -96,18 +96,18 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] [[package]] name = "syn" -version = "2.0.38" +version = "2.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" dependencies = [ "proc-macro2", "quote", @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.8" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" +checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" dependencies = [ "serde", "serde_spanned", @@ -137,9 +137,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.15" +version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ "indexmap", "serde", @@ -150,9 +150,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" [[package]] name = "version_check" @@ -162,9 +162,9 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "windows" -version = "0.58.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" +checksum = "7f919aee0a93304be7f62e8e5027811bbba96bcb1de84d6618be56e43f8a32a1" dependencies = [ "windows-core", "windows-targets", @@ -172,9 +172,9 @@ dependencies = [ [[package]] name = "windows-core" -version = "0.58.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" +checksum = "810ce18ed2112484b0d4e15d022e5f598113e220c53e373fb31e67e21670c1ce" dependencies = [ "windows-implement", "windows-interface", @@ -185,9 +185,9 @@ dependencies = [ [[package]] name = "windows-implement" -version = "0.58.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" +checksum = "83577b051e2f49a058c308f17f273b570a6a758386fc291b5f6a934dd84e48c1" dependencies = [ "proc-macro2", "quote", @@ -196,9 +196,9 @@ dependencies = [ [[package]] name = "windows-interface" -version = "0.58.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" +checksum = "cb26fd936d991781ea39e87c3a27285081e3c0da5ca0fcbc02d368cc6f52ff01" dependencies = [ "proc-macro2", "quote", @@ -207,28 +207,27 @@ dependencies = [ [[package]] name = "windows-result" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +checksum = "d08106ce80268c4067c0571ca55a9b4e9516518eaa1a1fe9b37ca403ae1d1a34" dependencies = [ "windows-targets", ] [[package]] name = "windows-strings" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +checksum = "b888f919960b42ea4e11c2f408fadb55f78a9f236d5eef084103c8ce52893491" dependencies = [ - "windows-result", "windows-targets", ] [[package]] name = "windows-targets" -version = "0.52.6" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +checksum = "b1e4c7e8ceaaf9cb7d7507c974735728ab453b67ef8f18febdd7c11fe59dca8b" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -242,66 +241,66 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.6" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" [[package]] name = "windows_aarch64_msvc" -version = "0.52.6" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" [[package]] name = "windows_i686_gnu" -version = "0.52.6" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" [[package]] name = "windows_i686_gnullvm" -version = "0.52.6" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" [[package]] name = "windows_i686_msvc" -version = "0.52.6" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" [[package]] name = "windows_x86_64_gnu" -version = "0.52.6" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.6" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" [[package]] name = "windows_x86_64_msvc" -version = "0.52.6" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" [[package]] name = "winnow" -version = "0.5.40" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603" dependencies = [ "memchr", ] [[package]] name = "winresource" -version = "0.1.17" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77e2aaaf8cfa92078c0c0375423d631f82f2f57979c2884fdd5f604a11e45329" +checksum = "7276691b353ad4547af8c3268488d1311f4be791ffdc0c65b8cfa8f41eed693b" dependencies = [ "toml", "version_check", diff --git a/crates/auto_mute_cli/Cargo.toml b/crates/auto_mute_cli/Cargo.toml index 34dfb17..d9048d3 100644 --- a/crates/auto_mute_cli/Cargo.toml +++ b/crates/auto_mute_cli/Cargo.toml @@ -4,9 +4,8 @@ version = "0.2.0" edition = "2021" [dependencies.windows] -version = "0.58.0" +version = "0.59.0" features = [ - "implement", "Win32_Media_Audio", "Win32_UI_Shell_PropertiesSystem", "Data_Xml_Dom", diff --git a/crates/auto_mute_gui/Cargo.toml b/crates/auto_mute_gui/Cargo.toml index 96d4cda..29d452e 100644 --- a/crates/auto_mute_gui/Cargo.toml +++ b/crates/auto_mute_gui/Cargo.toml @@ -8,10 +8,10 @@ winresource = "0.1.17" [dependencies] auto_mute_lib = { path = "../auto_mute_lib" } -windows-core = "0.58.0" +windows-core = "0.59.0" [dependencies.windows] -version = "0.58.0" +version = "0.59.0" features = [ "Win32_UI", "Win32_UI_Accessibility", diff --git a/crates/auto_mute_gui/src/main.rs b/crates/auto_mute_gui/src/main.rs index 3160942..bf79d55 100644 --- a/crates/auto_mute_gui/src/main.rs +++ b/crates/auto_mute_gui/src/main.rs @@ -1,16 +1,27 @@ -use std::{collections::HashSet, env, fs::File, io::{BufRead, BufReader}}; +use std::{ + collections::HashSet, + env, + fs::File, + io::{BufRead, BufReader}, +}; use auto_mute_lib::muter::MuterThread; -use windows::Win32::{Foundation::HWND, System::LibraryLoader::GetModuleHandleW, UI::{Shell::{Shell_NotifyIconW, NIF_ICON, NIF_MESSAGE, NIM_ADD, NOTIFYICONDATAW}, WindowsAndMessaging::{LoadIconW, WM_USER}}}; +use windows::Win32::{ + Foundation::HWND, + System::LibraryLoader::GetModuleHandleW, + UI::{ + Shell::{Shell_NotifyIconW, NIF_ICON, NIF_MESSAGE, NIM_ADD, NOTIFYICONDATAW}, + WindowsAndMessaging::{LoadIconW, WM_USER}, + }, +}; use windows_core::w; const WM_TRAY_MENU: u32 = WM_USER; pub struct MagicTray { - pub notifdata: NOTIFYICONDATAW + pub notifdata: NOTIFYICONDATAW, } - impl MagicTray { fn new() -> MagicTray { unsafe { @@ -21,9 +32,13 @@ impl MagicTray { uID: 1, uFlags: NIF_ICON | NIF_MESSAGE, uCallbackMessage: WM_TRAY_MENU, - hIcon: LoadIconW(GetModuleHandleW(None).unwrap(), w!("ICO_UNMUTE")).unwrap(), + hIcon: LoadIconW( + Some(GetModuleHandleW(None).unwrap().into()), + w!("ICO_UNMUTE"), + ) + .unwrap(), ..Default::default() - } + }, }; mt.init(); mt @@ -42,13 +57,15 @@ impl Default for MagicTray { } } - pub fn load_mute_txt(file_name: &str) -> HashSet { let file = File::open(file_name).unwrap(); HashSet::from_iter(BufReader::new(file).lines().map(|line| line.unwrap())) } fn main() { + let mut tray = MagicTray::default(); + tray.init(); + MuterThread::com_init(); let mute_file: String = env::args().nth(1).unwrap_or("mute.txt".to_string()); let _mt = MuterThread::new(load_mute_txt(&mute_file), None); diff --git a/crates/auto_mute_lib/Cargo.toml b/crates/auto_mute_lib/Cargo.toml index 2b2c9f1..c51f39c 100644 --- a/crates/auto_mute_lib/Cargo.toml +++ b/crates/auto_mute_lib/Cargo.toml @@ -4,12 +4,11 @@ version = "0.2.0" edition = "2021" [dependencies] -windows-core = "0.58.0" +windows-core = "0.59.0" [dependencies.windows] -version = "0.58.0" +version = "0.59.0" features = [ - "implement", "Win32_Media_Audio", "Win32_UI_Shell_PropertiesSystem", "Data_Xml_Dom", diff --git a/crates/auto_mute_lib/src/device_notification_client.rs b/crates/auto_mute_lib/src/device_notification_client.rs index 7e71b9c..d867425 100644 --- a/crates/auto_mute_lib/src/device_notification_client.rs +++ b/crates/auto_mute_lib/src/device_notification_client.rs @@ -1,4 +1,6 @@ -use windows::Win32::Media::Audio::{IMMNotificationClient, IMMNotificationClient_Impl, DEVICE_STATE}; +use windows::Win32::Media::Audio::{ + IMMNotificationClient, IMMNotificationClient_Impl, DEVICE_STATE, +}; pub trait DeviceNotificationObserver { fn add_device(&self, device_id: &windows::core::PCWSTR); } @@ -37,9 +39,9 @@ impl IMMNotificationClient_Impl for DeviceNotificationClient_Impl { fn OnPropertyValueChanged( &self, - _pwstrdeviceid: &windows::core::PCWSTR, - _key: &windows::Win32::UI::Shell::PropertiesSystem::PROPERTYKEY, - ) -> windows::core::Result<()> { + _pwstrdeviceid: &windows_core::PCWSTR, + _key: &windows::Win32::Foundation::PROPERTYKEY, + ) -> windows_core::Result<()> { Ok(()) } } diff --git a/crates/auto_mute_lib/src/session_notification.rs b/crates/auto_mute_lib/src/session_notification.rs index 89e3dee..e4faaa8 100644 --- a/crates/auto_mute_lib/src/session_notification.rs +++ b/crates/auto_mute_lib/src/session_notification.rs @@ -15,7 +15,7 @@ pub trait SessionObserver { } impl IAudioSessionNotification_Impl for SessionNotification_Impl { - fn OnSessionCreated(&self,newsession:Option<&IAudioSessionControl>) -> windows::core::Result<()> { + fn OnSessionCreated(&self,newsession:windows_core::Ref<'_, IAudioSessionControl>) -> windows::core::Result<()> { let ses: IAudioSessionControl2 = newsession.as_ref().unwrap().cast().unwrap(); self.observer.add_session(ses); Ok(()) diff --git a/crates/auto_mute_lib/src/window_change.rs b/crates/auto_mute_lib/src/window_change.rs index 25d9c93..2281905 100644 --- a/crates/auto_mute_lib/src/window_change.rs +++ b/crates/auto_mute_lib/src/window_change.rs @@ -4,7 +4,7 @@ use std::{ }; use windows::Win32::{ - Foundation::{HINSTANCE, HWND, LPARAM, WPARAM}, + Foundation::{HWND, LPARAM, WPARAM}, System::Threading::GetCurrentThreadId, UI::{ Accessibility::{SetWinEventHook, UnhookWinEvent, HWINEVENTHOOK}, @@ -53,7 +53,7 @@ pub fn await_win_change_events(callback: WinCallback) { let fg_event = SetWinEventHook( EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND, - HINSTANCE::default(), + None, Some(win_event_proc), 0, 0, @@ -62,7 +62,7 @@ pub fn await_win_change_events(callback: WinCallback) { let min_event = SetWinEventHook( EVENT_SYSTEM_MINIMIZEEND, EVENT_SYSTEM_MINIMIZEEND, - HINSTANCE::default(), + None, Some(win_event_proc), 0, 0, @@ -70,7 +70,7 @@ pub fn await_win_change_events(callback: WinCallback) { ); let mut msg: MSG = MSG::default(); - while GetMessageW(&mut msg, HWND::default(), 0, 0).0 > 0 { + while GetMessageW(&mut msg, None, 0, 0).0 > 0 { TranslateMessage(&msg).unwrap(); DispatchMessageW(&msg); }