Update windows-rs
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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<String> {
|
||||
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);
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(())
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user