Update windows-rs

This commit is contained in:
Your Name
2025-02-16 12:15:16 -05:00
parent 989c5c05a5
commit 16f5f49c99
8 changed files with 98 additions and 82 deletions

View File

@@ -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);