WindowMute 用来拦截某个进程新创建或新显示的窗口,并把这些窗口处理成不可见、透明点击穿透,或者直接挪到屏幕外。
window_mute.ps1: 主脚本find_window.ps1: 用来查目标窗口的进程名、类名、标题run_window_mute.vbs: 隐藏启动window_mute.ps1
- Windows
- PowerShell 5.1 或更高版本
- 允许当前进程通过
-ExecutionPolicy Bypass运行脚本
如果你已经知道目标进程名,可以先按进程过滤:
powershell -ExecutionPolicy Bypass -File .\find_window.ps1 -ProcessName <进程名>例如:
powershell -ExecutionPolicy Bypass -File .\find_window.ps1 -ProcessName WeChat如果你还不确定是谁在蒙屏,也可以先全局扫描大窗口:
powershell -ExecutionPolicy Bypass -File .\find_window.ps1重点看输出里的这些字段:
Process: 进程名Class: 窗口类名Title: 窗口标题Rect: 窗口位置和大小
如果同一个进程里不止一个窗口,建议优先记录 Class 或 Title,后面用来精准过滤,避免误伤正常窗口。
最简单的运行方式:
powershell -NoProfile -STA -ExecutionPolicy Bypass -File .\window_mute.ps1 -p <进程名>例如:
powershell -NoProfile -STA -ExecutionPolicy Bypass -File .\window_mute.ps1 -p WeChat如果你已经知道蒙版窗口的类名,可以只拦这一类窗口:
powershell -NoProfile -STA -ExecutionPolicy Bypass -File .\window_mute.ps1 -p WeChat -ClassPattern "Overlay|Mask|Qt5152QWindowIcon"如果你想按标题过滤:
powershell -NoProfile -STA -ExecutionPolicy Bypass -File .\window_mute.ps1 -p WeChat -TitlePattern "护眼|遮罩|overlay"也可以同时用:
powershell -NoProfile -STA -ExecutionPolicy Bypass -File .\window_mute.ps1 -p WeChat -ClassPattern "Overlay" -TitlePattern "mask"如果你不想看到 PowerShell 窗口,可以用:
run_window_mute.vbs使用前先编辑 run_window_mute.vbs,把里面的:
<ProcessName>
替换成真实进程名,例如:
WeChat
注意:
vbs启动后是隐藏后台进程- 这种方式没有控制台,所以不能用
Ctrl+C - 建议先把
ps1调试通,再切到vbs
window_mute.ps1 支持这些参数:
-p: 必填,目标进程名,比如WeChat或WeChat.exe-l: 日志路径,默认是D:\mute.txt-Mode: 处理模式,支持Transparent、Hide、Move-ClassPattern: 用正则匹配窗口类名-TitlePattern: 用正则匹配窗口标题-SweepIntervalMs: 兜底扫描间隔,默认2000
默认模式。窗口还存在,但会被设置成全透明并点击穿透。
适合:
- 想尽量少影响目标程序逻辑
- 只是不想看到这层蒙版
直接把窗口隐藏掉。
适合:
- 透明模式不够干净
- 目标窗口会抢焦点或仍然有副作用
把窗口挪到屏幕外。
适合:
- 某些程序对
Hide或Transparent反应异常时作为兜底方案
主脚本现在会同时:
- 写入日志文件
- 打印到当前终端
默认日志文件是:
D:\mute.txt
如果该盘不存在,可以手动指定:
powershell -NoProfile -STA -ExecutionPolicy Bypass -File .\window_mute.ps1 -p WeChat -l D:\temp\window_mute.txt如果你是直接在控制台里运行:
powershell -NoProfile -STA -ExecutionPolicy Bypass -File .\window_mute.ps1 -p WeChat可以直接按:
Ctrl+C
脚本会优雅退出并释放钩子。
如果你是通过 run_window_mute.vbs 启动的,因为没有控制台,Ctrl+C 不可用。
可以用下面这条命令定向结束对应脚本进程:
Get-CimInstance Win32_Process |
Where-Object { $_.Name -eq 'powershell.exe' -and $_.CommandLine -like '*window_mute.ps1*' } |
ForEach-Object { Stop-Process -Id $_.ProcessId }也可以在任务管理器里结束对应的 powershell.exe 进程。
- 用
find_window.ps1找到目标进程和窗口类名 - 先直接运行
window_mute.ps1 - 优先尝试
Transparent - 如果效果不理想,再试
Hide - 确认稳定后,再改用
run_window_mute.vbs后台启动
只拦截某个进程的指定类名窗口:
powershell -NoProfile -STA -ExecutionPolicy Bypass -File .\window_mute.ps1 -p WeChat -ClassPattern "Qt5152QWindowIcon" -Mode Transparent按标题过滤并使用隐藏模式:
powershell -NoProfile -STA -ExecutionPolicy Bypass -File .\window_mute.ps1 -p WeChat -TitlePattern "遮罩|蒙版" -Mode Hide降低兜底扫描频率,进一步减少空闲开销:
powershell -NoProfile -STA -ExecutionPolicy Bypass -File .\window_mute.ps1 -p WeChat -SweepIntervalMs 5000ClassPattern和TitlePattern都是正则表达式,不是普通包含匹配- 如果过滤条件太宽,可能会把目标进程里的正常窗口一起处理掉
- 如果过滤条件太窄,可能会漏掉动态生成的新窗口
Transparent通常更温和,Hide更强硬- 日志默认写到
D:\mute.txt,如果该盘不存在,请用-l改路径