The functionality of ms-screenclip is the same as ms-screensktech on Windows 11.

Tamás Bitó 20 Reputation points
2024-04-17T08:48:03.8766667+00:00

In my C# uwp project I want to make the state of the snipping tool appear when the combination windows + shift + s is pressed.

I have the same implementation as the official documentation says:

    bool result = await Launcher.LaunchUriAsync(new Uri("ms-screenclip:edit?source=SOURCE"));

It works fine in windows 10 operation system, but on Windows 11 it behaves as if I give the ms-screensketch command, so it lanuches only the snipping tool and i need to click on new screenshot. Can you help me how can i get the same functionallity as win10 operation system?

Universal Windows Platform (UWP)
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,266 questions
0 comments No comments
{count} votes

Accepted answer
  1. Roy Li - MSFT 32,011 Reputation points Microsoft Vendor
    2024-04-18T02:31:50.8766667+00:00

    Hello,

    Welcome to Microsoft Q&A!

    Can you help me how can i get the same functionallity as win10 operation system?

    A workaround is that you could try to inject combined key inputs from code so you could directly start the snipping function like the old behavior in Windows 10.

    Before we start to use the InputInjector Class, we will need to add inputInjectionBrokered restricted capability into the manifest file first.

    <Package
       ...
       xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
     IgnorableNamespaces="uap mp rescap">
    

    And in the Capabilities selection

    <Capabilities>
      <Capability Name="internetClient" />
      <rescap:Capability Name="inputInjectionBrokered" />
    </Capabilities>
    

    Then you could use the following code to inject keyboard input to directly start the snipping function.

        private  void Button_Click(object sender, RoutedEventArgs e)
        {
            //press key
            InputInjector inputInjector = InputInjector.TryCreate();
    
            var shift = new InjectedInputKeyboardInfo();
            shift.VirtualKey = (ushort)(VirtualKey.Shift);
            shift.KeyOptions = InjectedInputKeyOptions.ExtendedKey;
    
    
            var win = new InjectedInputKeyboardInfo();
            win.VirtualKey = (ushort)(VirtualKey.LeftWindows);
            win.KeyOptions = InjectedInputKeyOptions.ExtendedKey;
    
    
            var skey = new InjectedInputKeyboardInfo();
            skey.VirtualKey = (ushort)(VirtualKey.S);
            skey.KeyOptions = InjectedInputKeyOptions.None;
    
    
            inputInjector.InjectKeyboardInput(new[] { shift, win,skey });
    
            // release shift and win key
            shift.KeyOptions = InjectedInputKeyOptions.KeyUp;
            win.KeyOptions = InjectedInputKeyOptions.KeyUp;
            inputInjector.InjectKeyboardInput(new[] { shift, win });
    
    
            //bool result = await Launcher.LaunchUriAsync(new Uri("ms-screenclip: edit ? source = SOURCE"));
        }
    
    

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful