SnippingTool命令行参数有哪些?

99ANYc3cd6
预计阅读时长 18 分钟
位置: 首页 参数 正文

现代版本的 Windows 10 和 Windows 11 中,SnippingTool.exe 的命令行参数非常有限,主要功能是启动应用程序本身,而不是直接进行截图。

snippingtool 参数
(图片来源网络,侵删)

与功能更强大的 Snip & Sketch(快捷键 Win + Shift + S)或更古老的 SnippingTool.exe(在旧版 Windows 中)相比,新版截图工具的参数化能力被大大削弱了。


主要可用参数

经过测试,新版 SnippingTool.exe 支持以下参数:

无参数 (最常见用法)

直接运行 SnippingTool.exe 会打开应用程序窗口,等待用户手动点击“新建”按钮进行截图。

SnippingTool.exe

显示命令行的帮助信息,如果你不确定有哪些参数,这是第一个应该尝试的。

snippingtool 参数
(图片来源网络,侵删)
SnippingTool.exe /?

执行后,通常会显示类似以下内容:

SnippingTool.exe
SnippingTool.exe /?
Usage: SnippingTool.exe [/?]
/?      : Show this help message.

这表明它除了帮助信息外,几乎没有其他可用的参数。

/screenshot (仅限特定版本/环境)

在某些测试版或特定版本的 Windows 中,可能存在 /screenshot 参数,它会立即启动截图模式,而无需打开主窗口。但在大多数公开发布的稳定版 Windows 10/11 中,此参数可能无效或已被移除。

如果你尝试使用它,系统可能会提示“无法识别的命令行参数”或直接忽略它。

snippingtool 参数
(图片来源网络,侵删)
SnippingTool.exe /screenshot

重要说明:为什么参数这么少?

  1. 设计理念的转变:新版截图工具的设计重点是成为一个快速、无干扰的截图工具,它的核心交互是通过全局快捷键 Win + Shift + S 来触发的,而不是通过命令行。
  2. 功能整合:截图工具的功能已经与“草图和素描”(Snip & Sketch)深度整合,截图的体验主要由 Win + Shift + S 快捷键和屏幕底部的通知栏来管理。
  3. 自动化场景的替代方案:如果你需要通过脚本或命令行来自动截图,SnippingTool.exe 并不是最佳选择,你应该使用功能更强大的工具,PowerShell 或第三方工具。

实际应用场景与替代方案

虽然 SnippingTool.exe 本身参数有限,但你可以通过其他方式实现自动化截图。

场景1:通过快捷键启动截图工具

你可以在脚本中模拟按键,来触发 Win + Shift + S 快捷键。

使用 PowerShell 模拟按键:

# 添加 .NET 程序集以使用 SendKeys 类
Add-Type -AssemblyName System.Windows.Forms
# 模拟按下 Win + Shift + S
[System.Windows.Forms.SendKeys]::SendWait("^%{s}") 
# 注意:在 SendKeys 中,^ 代表 Ctrl,% 代表 Alt,+ 代表 Shift。
# Win 键通常被视为一个修饰键,组合方式可能因系统而异。
# 更可靠的方式是直接调用快捷键的功能,而不是模拟按键。
# 更现代和可靠的方法是调用 Windows Runtime API
# 以下代码需要 PowerShell 7+ 或在 Windows 10/11 上运行
Add-Type -Path "C:\Program Files\WindowsApps\Microsoft.ScreenSketch_*\ScreenSketch.dll" -ErrorAction SilentlyContinue
if ([ScreenCapture]::CaptureWithUI()) {
    Write-Host "截图工具已通过 UI 启动。"
} else {
    Write-Host "无法启动截图工具。"
}

注意:直接调用 DLL 文件路径不稳定,因为版本号会变,模拟按键也不是最可靠的方法。

场景2:使用 PowerShell 进行自动化截图(推荐)

PowerShell 提供了更强大、更可靠的截图方法,无需依赖任何 GUI 应用程序。

示例:截取整个活动窗口并保存为文件

# 定义输出文件路径
$outputPath = "$env:USERPROFILE\Desktop\Screenshot_$(Get-Date -Format 'yyyyMMdd_HHmmss').png"
# 使用 Windows API 获取窗口设备上下文并进行截图
Add-Type -TypeDefinition @"
using System;
using System.Drawing;
using System.Runtime.InteropServices;
public class ScreenCapture {
    [DllImport("user32.dll")]
    private static extern IntPtr GetWindowDC(IntPtr hWnd);
    [DllImport("user32.dll")]
    private static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
    [DllImport("gdi32.dll")]
    private static extern bool BitBlt(IntPtr hObject, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hObjectSource, int nXSrc, int nYSrc, int dwRop);
    [DllImport("gdi32.dll")]
    private static extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int nWidth, int nHeight);
    [DllImport("gdi32.dll")]
    private static extern IntPtr CreateCompatibleDC(IntPtr hDC);
    [DllImport("gdi32.dll")]
    private static extern bool DeleteObject(IntPtr hObject);
    [StructLayout(LayoutKind.Sequential)]
    public struct RECT {
        public int Left;
        public int Top;
        public int Right;
        public int Bottom;
    }
    public static void CaptureActiveWindow(string filePath) {
        IntPtr hWnd = GetForegroundWindow(); // 获取当前活动窗口句柄
        GetWindowRect(hWnd, out RECT rc);
        int width = rc.Right - rc.Left;
        int height = rc.Bottom - rc.Top;
        IntPtr hdcSrc = GetWindowDC(hWnd);
        IntPtr hdcDest = CreateCompatibleDC(hdcSrc);
        IntPtr hBitmap = CreateCompatibleBitmap(hdcSrc, width, height);
        IntPtr hOld = SelectObject(hdcDest, hBitmap);
        BitBlt(hdcDest, 0, 0, width, height, hdcSrc, 0, 0, 0x00CC0020 /*SRCCOPY*/);
        Bitmap bmp = Image.FromHbitmap(hBitmap);
        bmp.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
        // 清理资源
        SelectObject(hdcDest, hOld);
        DeleteObject(hBitmap);
        DeleteObject(hdcDest);
        DeleteObject(hdcSrc);
    }
    [DllImport("user32.dll")]
    private static extern IntPtr GetForegroundWindow();
    [DllImport("gdi32.dll")]
    private static extern IntPtr SelectObject(IntPtr hdc, IntPtr hObject);
}
"@
# 调用函数进行截图
[ScreenCapture]::CaptureActiveWindow($outputPath)
Write-Host "截图已保存到: $outputPath"

这个 PowerShell 脚本可以完美地集成到你的自动化流程中,无需手动干预。

工具 命令行参数 主要用途 推荐场景
新版 SnippingTool.exe 几乎无 () 手动截图,通过快捷键触发 普通用户日常截图
PowerShell 功能强大 脚本化、自动化截图 开发、IT运维、需要自动化的高级用户
第三方工具 各不相同,通常功能丰富 高级截图(滚动截图、OCR、标注等) 专业用户、有特殊需求的场景

对于你的问题,SnippingTool.exe 的参数基本可以忽略不计,如果你需要通过命令行或脚本控制截图,请直接使用 PowerShell 或其他专业工具。

-- 展开阅读全文 --
头像
华为MateBook D拆机图藏着什么秘密?
« 上一篇 今天
华为Mate7智能遥控如何实现设备连接与功能?
下一篇 » 今天

相关文章

取消
微信二维码
支付宝二维码

最近发表

标签列表

目录[+]