Win11中C# UWP调用ms-screenclip与Win10表现差异问题咨询
在Windows 11 UWP中实现Win10风格的一键截图功能
Windows 11对ms-screenclip: URI的行为做了调整,原有的edit?source=SOURCE参数不再直接触发截图状态,仅会打开截图工具界面。要实现和Win10一致的直接进入截图(类似Win+Shift+S)的效果,可采用以下两种方案:
方案1:使用ms-screensketch: URI参数(推荐)
Win11及Win10 1809+版本支持ms-screensketch:take URI,通过指定mode参数可直接触发对应截图模式,无需手动点击"新建"。
示例代码:
bool result = await Launcher.LaunchUriAsync(new Uri("ms-screensketch:take?mode=region")); if (result) { Clipboard.ContentChanged += Screenshot_Succeeded; }
可选的mode参数值:
region:区域截图(对应Win+Shift+S默认模式)fullscreen:全屏截图window:窗口截图rectangle:矩形截图
该方案无需额外配置,跨Win10/Win11兼容,实现成本最低。
方案2:通过FullTrust进程调用SnippingTool.exe
如果需要完全模拟Win+Shift+S的原生行为,可通过UWP的FullTrustProcessLauncher调用系统自带的SnippingTool.exe并传入/clip参数。
步骤1:配置Package.appxmanifest
添加FullTrust进程扩展:
<Package ...> <Applications> <Application ...> <!-- 其他内容 --> <Extensions> <uap:Extension Category="windows.fullTrustProcess" Executable="SnippingTool.exe"> <uap:FullTrustProcess> <uap:ParameterGroup GroupId="SnippingToolClip" Parameters="/clip" /> </uap:FullTrustProcess> </uap:Extension> </Extensions> </Application> </Applications> </Package>
步骤2:调用FullTrust进程
using Windows.ApplicationModel; // 启动截图工具并触发截图 await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync("SnippingToolClip"); // 监听截图完成事件 Clipboard.ContentChanged += Screenshot_Succeeded;
注意:
- 需在项目中引用
Windows Desktop Extensions for the UWP(版本需匹配目标系统) - 该方案需要将应用打包部署,无法在调试模式直接运行
内容的提问来源于stack exchange,提问作者tAMBI99
相关产品推荐
相关产品推荐

