question

TomJD1Xue-4470 avatar image
0 Votes"
TomJD1Xue-4470 asked TomJD1Xue-4470 edited

How to invoke Snipping Tool or Snip & Sketch to open my screenshot

I am developing my own screenshot app. And I hope when I take a screenshot, which is in my app, then I could invoke Snipping Tool or Snip & Sketch to open the screenshot in them. So that I could further edit it in them. Is it possible and how?

I tried Snip & Sketch, it can do so. When it takes a screenshot, then use its "Open With", it can invoke any other app, like Paint, Photos or another Snip & Sketch to open the screenshot in them and then do edit work.

Follow above process, Snip & Sketch can also invoke Snipping Tool. But the invoked Snipping Tool won't open the screenshot.

windows-wpf
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Castorix31 avatar image
0 Votes"
Castorix31 answered

I did a test from MSDN UWP sample which worked in WPF, at least on my OS (Windows 10 21H1)

Change the SDK version in those paths if it is different in your installation (mine is 10.0.19041.0):

 // Add reference to : "C:\Program Files (x86)\Windows Kits\10\References\10.0.19041.0\Windows.Foundation.UniversalApiContract\10.0.0.0\Windows.Foundation.UniversalApiContract.winmd"
 // Add reference to : "C:\Program Files (x86)\Windows Kits\10\References\10.0.19041.0\Windows.Foundation.FoundationContract\4.0.0.0\Windows.Foundation.FoundationContract.winmd"
 // Add reference to : "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll"
 // Add reference to : "C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.19041.0\Facade\Windows.winmd"

Test with a random file "E:\butterfly.png", in a Button click :

     private void Button_Click(object sender, RoutedEventArgs e)
     {
         LaunchUri();
     }

     private async void LaunchUri()
     {
         string sPath = @"E:\butterfly.png";
         var file = await Windows.Storage.StorageFile.GetFileFromPathAsync(sPath);
         var sToken = Windows.ApplicationModel.DataTransfer.SharedStorageAccessManager.AddFile(file);
    
         var sUri = String.Format("ms-screensketch:edit?source=MyApp&isTemporary=false&sharedAccessToken={0}", sToken);
         bool bResult = await Windows.System.Launcher.LaunchUriAsync(new Uri(sUri));

         if (bResult)
         {
             // URI launched
         }
         else
         {
             // URI launch failed
         }
     }

and I get the file correctly opened (french version of Snip & Sketch) :

194314-screensketch.jpg



screensketch.jpg (70.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Castorix31 avatar image
1 Vote"
Castorix31 answered TomJD1Xue-4470 commented

Did you see Launch screen snipping ?


· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you very much! I tried it and it works!
But this is UWP method, and my application is WPF based.
Do you know how to achieve it in WPF method?

0 Votes 0 ·

But this is UWP method, and my application is WPF based.

Then change the Tag : you have set windows-app-sdk, which is not WPF related


0 Votes 0 ·

OK, changed. Thanks!

0 Votes 0 ·
TomJD1Xue-4470 avatar image
0 Votes"
TomJD1Xue-4470 answered TomJD1Xue-4470 edited

Another thing is that "Launch screen snipping" works by share a file based on UWP. While Snip & Sketch can share its screenshot (in memory) via "Open With" to other app.
Do we have this in memory screenshot sharing method?
And do we have WPF based method?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TomJD1Xue-4470 avatar image
0 Votes"
TomJD1Xue-4470 answered Castorix31 commented

@Castorix31
Thank you for your reply!
I tried your code, but get below error.
And my application is WPF based, do you know how to achieve it in WPF?

194510-image.png



image.png (279.4 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

And my application is WPF based, do you know how to achieve it in WPF?

As I said, I tested in WPF ...
Use a filepath where you have write rights, like in %localappdata%

0 Votes 0 ·
TomJD1Xue-4470 avatar image
0 Votes"
TomJD1Xue-4470 answered TomJD1Xue-4470 edited

@Castorix31 Thank you for your answer! I verified that your code works in WPF.
The only thing unclear to me now is that Snip & Sketch seems to have ability to "Open With" its screenshot in memory with other apps.
Maybe it saves the screenshot as a file and then share it with other app...

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.