简体   繁体   中英

How do I take a screenshot from an UWP?

I want to read my bluetooth le heart rate sensor output programmatically.

  • I tried c#, but it seems I need to use uwp.
  • I tried taking a screenshot in uwp - forbidden.
  • I tried executing an external program that takes a screenshot - forbidden.
  • I tried to send keystrokes Win - Printscreen to take a screenshot - forbidden.

How do I take a screenshot from an UWP?

To your first point, most of the Bluetooth APIs are marked with the DualApiPartionAttribute - that means they can be called from UWP or a regular Win32/Winforms/WPF/.NET application. Visual Studio doesn't make this easy to reference for you yet. You need to first add the reference to the union Windows.WinMD for the version of windows you want to target, ie:

  • C:\\Program Files (x86)\\Windows Kits\\10\\UnionMetadata\\10.0.16299.0\\Windows.Winmd

and since many of apis are Async() you'll need to reference:

  • C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\System.Runtime.WindowsRuntime.dll

Then the sample code looks essentially the same as UWP but called from your .NET app:

To your other questions about Screen capture, starting in Windows 1803, windows added a new Graphics Capture capability and apis. These classes are also marked DualApiPartitionAttribute so you can call them from either UWP or your Win32/.NET application. You can find more about them here:

Hope this helps,
-Adam

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM