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