A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.
Rust archive-managerdesktop-appdual-paneexplorer-alternativefile-browserfile-explorerfile-managerfluent-designgpu-acceleratedgpuimacosmicaproductivityquick-lookrustrust-guitabswindowswindows-11windows-explorer
//! Explorer's own "Automatically hide the taskbar" while the Dock hides the taskbar.
//!
//! WHY: the Dock hides Explorer's taskbar windows once it runs, but at sign-in Explorer is up some seconds before rustyfiles, and
//! its taskbar was seen every time until the Dock came. With Explorer's own auto-hide on, Explorer starts with its taskbar already
//! out of sight, so the Dock is the first bar seen.
//!
//! WHAT IT MEANS FOR THE DOCK'S ROOM. A taskbar that hides itself reserves no strip, and it slides in and out; at each of those
//! moves, and whenever any program's toolbar changes, Explorer computes the work areas anew from its own toolbar list. 1.0.7 to 1.0.10
//! turned auto-hide on and still kept the dock's room by setting the work area themselves: measured on a PC with two monitors
//! (2026-12-04), that rectangle was wiped five times in the eight seconds after a dock start and came back only after the answer's
//! growing pause (up to a minute), and the second monitor never got its room at all (issues 883, 888, 999). While auto-hide is on
//! the dock therefore keeps its bands REGISTERED WITH EXPLORER, on every monitor (`rf_shellguard::tbctl`, `explorer_keeps_bands`;
//! `rf_win::dock::system`), and sets no work area: on the same PC those bands held through every recomputation that was forced.
//!
//! The rule: [`engage`] (the hide is wanted) notes the user's own value once, in `taskbar-autohide-before` in the settings folder,
//! and turns auto-hide on; [`release`] (the hide was turned off, the Dock was switched off or told to stop, or rustyfiles is
//! uninstalled) puts the noted value back and removes the note. A plain shutdown (signing out, the PC going down) does neither:
//! the setting has to stay on for the next sign-in. A crash leaves auto-hide on, which
//! is harmless (the taskbar still slides up at the screen's edge) and is undone the next time the hide is turned off.
//!
//! The change goes through `SHAppBarMessage(ABM_SETSTATE)`, as the Settings app's switch does (Explorer keeps it in its own
//! `StuckRects3` value); it sends a message to Explorer, so it is never called on an interface thread.
use std::path::{Path, PathBuf};
use windows::Win32::UI::Shell::{ABM_GETSTATE, ABM_SETSTATE, ABS_ALWAYSONTOP, ABS_AUTOHIDE, APPBARDATA, SHAppBarMessage};
use windows::Win32::UI::WindowsAndMessaging::FindWindowW;
use windows::core::w;
/// The note of the user's own value, in the settings folder.
pub const NOTE_FILE: &str = "taskbar-autohide-before";
/// Whether Explorer's auto-hide is on now (`None` without Explorer's taskbar).
pub fn get() -> Option<bool> {
let tray = unsafe { FindWindowW(w!("Shell_TrayWnd"), None) }.ok()?;
let mut d = APPBARDATA { cbSize: std::mem::size_of::<APPBARDATA>() as u32, hWnd: tray, ..Default::default() };
let state = unsafe { SHAppBarMessage(ABM_GETSTATE, &mut d) } as u32;
Some(state & ABS_AUTOHIDE != 0)
}
/// Turns Explorer's auto-hide on or off (keeping "always on top", which every Windows since 7 forces anyway).
pub fn set(on: bool) -> bool {
let Ok(tray) = (unsafe { FindWindowW(w!("Shell_TrayWnd"), None) }) else { return false };
let mut d = APPBARDATA { cbSize: std::mem::size_of::<APPBARDATA>() as u32, hWnd: tray, ..Default::default() };
d.lParam = windows::Win32::Foundation::LPARAM((if on { ABS_AUTOHIDE } else { 0 } | ABS_ALWAYSONTOP) as isize);
unsafe { SHAppBarMessage(ABM_SETSTATE, &mut d) };
get() == Some(on)
}
fn note(dir: &Path) -> PathBuf {
dir.join(NOTE_FILE)
}
/// What the note says the user's own value was (`None`: no note).
pub fn noted(dir: &Path) -> Option<bool> {
std::fs::read_to_string(note(dir)).ok().map(|s| s.trim() == "1")
}
/// The hide is wanted: the user's value is noted (only when no note is there yet, so a second engage never notes our own "on"),
/// then auto-hide goes on. Without Explorer's taskbar nothing is done.
pub fn engage(dir: &Path) {
let Some(now) = get() else { return };
if noted(dir).is_none() && std::fs::write(note(dir), if now { "1" } else { "0" }).is_err() {
// without a note the value could not be put back: better not to change it
log::warn!("taskbar auto-hide: the user's value could not be noted; left as it is");
return;
}
if !now && !set(true) {
log::warn!("taskbar auto-hide: could not be turned on");
}
}
/// The hide is no longer wanted: the noted value goes back and the note goes. Nothing is done without a note.
pub fn release(dir: &Path) {
let Some(before) = noted(dir) else { return };
if get().is_some() && get() != Some(before) && !set(before) {
log::warn!("taskbar auto-hide: the user's value could not be put back; the note is kept for the next try");
return;
}
let _ = std::fs::remove_file(note(dir));
}
#[cfg(test)]
mod tests {
#[test]
fn the_note_reads_back_and_a_missing_note_is_none() {
let dir = std::env::temp_dir().join(format!("rf-autohide-test-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
assert_eq!(super::noted(&dir), None);
std::fs::write(dir.join(super::NOTE_FILE), "1").unwrap();
assert_eq!(super::noted(&dir), Some(true));
std::fs::write(dir.join(super::NOTE_FILE), "0\n").unwrap();
assert_eq!(super::noted(&dir), Some(false));
let _ = std::fs::remove_dir_all(&dir);
}
}
#[cfg(test)]
mod live {
/// By hand, on a real desktop (it changes the taskbar's auto-hide for a moment and puts it back; makes the sign-in task and
/// removes it): `cargo test -p rf-win --lib taskbar_autohide::live -- --ignored --nocapture`.
#[test]
#[ignore]
fn engage_and_release_put_the_users_value_back_and_the_sign_in_task_comes_and_goes() {
let dir = std::env::temp_dir().join(format!("rf-autohide-live-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let before = super::get().expect("Explorer's taskbar");
super::engage(&dir);
assert_eq!(super::get(), Some(true), "auto-hide on while the hide is wanted");
assert_eq!(super::noted(&dir), Some(before), "the user's value noted");
super::engage(&dir);
assert_eq!(super::noted(&dir), Some(before), "a second engage keeps the first note");
super::release(&dir);
assert_eq!(super::get(), Some(before), "the user's value is back");
assert_eq!(super::noted(&dir), None, "and the note is gone");
let _ = std::fs::remove_dir_all(&dir);
let exe = std::env::current_exe().unwrap();
let name = format!("rustyfiles start ({})", std::env::var("USERNAME").unwrap_or_default());
let query = || std::process::Command::new("schtasks").args(["/Query", "/TN", &name]).output().map(|o| o.status.success()).unwrap_or(false);
crate::dialogs::set_sign_in_task(&exe, true).expect("made without administrator rights");
assert!(query(), "the task is there");
let xml = std::process::Command::new("schtasks").args(["/Query", "/TN", &name, "/XML"]).output().unwrap();
let xml = String::from_utf8_lossy(&xml.stdout).into_owned();
eprintln!("{}", xml.lines().filter(|l| l.contains("LogonTrigger") || l.contains("Priority") || l.contains("Command") || l.contains("Arguments") || l.contains("RunLevel")).collect::<Vec<_>>().join("\n"));
crate::dialogs::set_sign_in_task(&exe, false).unwrap();
assert!(!query(), "and gone");
}
}