Launch elevated Terminal profile without a keyboard #19034

Closed
opened 2026-01-31 06:31:57 +00:00 by claunia · 17 comments
Owner

Originally created by @nguyen-dows on GitHub (Dec 8, 2022).

Description of the new feature/enhancement

Today, there is no way to launch an elevated Terminal profile end-to-end without the need to use a keyboard.

Even without a physical keyboard, the user flow is still the same with a on-screen keyboard:

  1. Launch Terminal
  2. Ctrl + Click the profile you want to open

This Feature Request proposes a way for a user to open an elevated Terminal profile without the need to use a keyboard.
This is a very common Accessibility scenario.
The user should be able to launch an elevated Terminal profile with just a touch screen and / or mouse.

For more details see: https://twitter.com/SBarizien/status/1599769771666391042

Originally created by @nguyen-dows on GitHub (Dec 8, 2022). # Description of the new feature/enhancement Today, there is no way to launch an elevated Terminal profile end-to-end without the need to use a keyboard. Even without a physical keyboard, the user flow is still the same with a on-screen keyboard: 1) Launch Terminal 2) Ctrl + Click the profile you want to open This Feature Request proposes a way for a user to open an elevated Terminal profile without the need to use a keyboard. This is a very common Accessibility scenario. The user should be able to launch an elevated Terminal profile with just a touch screen and / or mouse. For more details see: https://twitter.com/SBarizien/status/1599769771666391042
Author
Owner

@zadjii-msft commented on GitHub (Dec 9, 2022):

Were there any suggestions for how to do that?

The only thing I could think of was some default nested actions for opening a new elevated profile in the Command Palette. Trick here is the wording - we don't want to open a new window always, but we'll need to if the terminal isn't already elevated.

Maybe just "Open Elevated > {profiles}"?

@zadjii-msft commented on GitHub (Dec 9, 2022): Were there any suggestions for how to do that? The only thing I could think of was some default nested actions for opening a new elevated profile in the Command Palette. Trick here is the wording - we don't want to open a new window always, but we'll need to if the terminal isn't already elevated. Maybe just "Open Elevated > {profiles}"?
Author
Owner

@237dmitry commented on GitHub (Dec 9, 2022):

As a workaround you can elevate current profile or execute command in elevated state with gsudo via UAC confirmation.

@237dmitry commented on GitHub (Dec 9, 2022): As a workaround you can elevate current profile or execute command in elevated state with [gsudo](https://github.com/gerardog/gsudo/releases) via UAC confirmation.
Author
Owner

@DHowett commented on GitHub (Dec 9, 2022):

@zadjii-msft I thought of this, which is everyone's favorite UI:

image

It's a right-click menu item with a right-click menu. It also works with touch (touch-hold-release!)

@DHowett commented on GitHub (Dec 9, 2022): @zadjii-msft I thought of this, which is everyone's favorite UI: ![image](https://user-images.githubusercontent.com/189190/206790820-903e0b70-5d67-4053-a334-9250ea9ae9b0.png) It's a right-click menu item _with a right-click menu_. It also works with touch (touch-hold-release!)
Author
Owner

@DHowett commented on GitHub (Dec 9, 2022):

If we did that, we could also put the splits in it...!

@DHowett commented on GitHub (Dec 9, 2022): If we did that, we could also put the splits in it...!
Author
Owner

@zadjii-msft commented on GitHub (Dec 9, 2022):

can we add right click context menus to menu flyouts?

@zadjii-msft commented on GitHub (Dec 9, 2022): _can_ we add right click context menus to menu flyouts?
Author
Owner

@DHowett commented on GitHub (Dec 9, 2022):

I gave it a shot in XAML Studio!

image

        <Rectangle Width="100" Height="100" Fill="Yellow">
            <Rectangle.ContextFlyout>
                <MenuFlyout>
                    <MenuFlyoutItem Text="First" />
                    <MenuFlyoutItem Text="Second">
                        <MenuFlyoutItem.ContextFlyout>
                            <MenuFlyout>
                                <MenuFlyoutItem Text="Well I'll Be..." />
                            </MenuFlyout>
                        </MenuFlyoutItem.ContextFlyout>
                    </MenuFlyoutItem>
                </MenuFlyout>
            </Rectangle.ContextFlyout>
        </Rectangle>
@DHowett commented on GitHub (Dec 9, 2022): I gave it a shot in XAML Studio! ![image](https://user-images.githubusercontent.com/189190/206792681-b2e54028-cbf6-4db6-8cef-d085652be01d.png) ```xaml <Rectangle Width="100" Height="100" Fill="Yellow"> <Rectangle.ContextFlyout> <MenuFlyout> <MenuFlyoutItem Text="First" /> <MenuFlyoutItem Text="Second"> <MenuFlyoutItem.ContextFlyout> <MenuFlyout> <MenuFlyoutItem Text="Well I'll Be..." /> </MenuFlyout> </MenuFlyoutItem.ContextFlyout> </MenuFlyoutItem> </MenuFlyout> </Rectangle.ContextFlyout> </Rectangle> ```
Author
Owner

@zadjii-msft commented on GitHub (Dec 9, 2022):

Damn, yea let's do that. ez.

@zadjii-msft commented on GitHub (Dec 9, 2022): Damn, yea let's do that. ez.
Author
Owner

@michalnpl commented on GitHub (Apr 14, 2023):

I've got a kind of fix for it. The tasks in Jumplist do not support custom menus, AFAIK. But I added the context menu to the profiles flyout. However, the context menu is wrong-positioned, and I have trouble determining why. It works correctly with localization and elevation; just the positioning is off. I used BottomEdgeAlignedLeft on profileMenuItem and experimented with all combinations, always getting it off.

runasoff

@michalnpl commented on GitHub (Apr 14, 2023): I've got a kind of fix for it. The tasks in Jumplist do not support custom menus, AFAIK. But I added the context menu to the profiles flyout. However, the context menu is wrong-positioned, and I have trouble determining why. It works correctly with localization and elevation; just the positioning is off. I used **BottomEdgeAlignedLeft** on **profileMenuItem** and experimented with all combinations, always getting it off. ![runasoff](https://user-images.githubusercontent.com/25628581/231909244-8632a357-3426-480a-b7e4-bd1e93bf07e2.png)
Author
Owner

@zadjii-msft commented on GitHub (Apr 20, 2023):

W E I R D. Xaml does have a tendency to do all sorts of weird stuff like that. Just recently I saw something weird like that with CommandBarFlyout where just switching to the Microsoft.UI.Xaml version (from Windows.UI.Xaml) magically fixed something.

@michalnpl any chance you've got a branch to share? Maybe I could take a look.

@zadjii-msft commented on GitHub (Apr 20, 2023): W E I R D. Xaml does have a tendency to do all sorts of weird stuff like that. Just recently I saw something weird like that with CommandBarFlyout where just switching to the Microsoft.UI.Xaml version (from Windows.UI.Xaml) magically fixed something. @michalnpl any chance you've got a branch to share? Maybe I could take a look.
Author
Owner

@michalnpl commented on GitHub (Apr 21, 2023):

Sure @zadjii-msft here is the branch

Don't forget to regenerate resources (added items to .resw).

Interestingly Shift+F10 (shortcut to invoke context menu) opens the context menu in the right place while right-clicking on the item opens it completely misaligned.

@michalnpl commented on GitHub (Apr 21, 2023): Sure @zadjii-msft here is the [branch](/michalnpl/terminal/tree/michalnpl/Launch_elevated_Terminal_profile_without_a_keyboard) Don't forget to regenerate resources (added items to .resw). Interestingly Shift+F10 (shortcut to invoke context menu) opens the context menu in the right place while right-clicking on the item opens it completely misaligned.
Author
Owner

@zadjii-msft commented on GitHub (May 17, 2023):

@michalnpl Sorry this got lost in my list of open tabs 😅

I'm betting that it's something with

        runAsAdminContextMenu.ShowAt(profileMenuItem);

Like, I'd hope that works. But I'd bet that XAML islands does something weird with flyouts like that. I know there were issues with DPI scaling of mouse events in XAML islands before, so I wouldn't be surprised here.

This might be a crazy idea, but I bet you could just manually ask XAML to show the flyout at the cursor position. Something like:

ce60bf290a/src/cascadia/TerminalControl/TermControl.cpp (L3386-L3404)

but instead of a "control-relative position", use CoreWindow::GetForCurrentThread().PointerPosition(). That's my thought at least.

@zadjii-msft commented on GitHub (May 17, 2023): @michalnpl Sorry this got lost in my list of open tabs 😅 I'm betting that it's something with ```c++ runAsAdminContextMenu.ShowAt(profileMenuItem); ``` Like, I'd _hope_ that works. But I'd _bet_ that XAML islands does something weird with flyouts like that. I _know_ there were issues with DPI scaling of mouse events in XAML islands before, so I wouldn't be surprised here. This might be a crazy idea, but I bet you could just manually ask XAML to show the flyout at the cursor position. Something like: https://github.com/microsoft/terminal/blob/ce60bf290a1750c9cf00d4fbe35715d946748d76/src/cascadia/TerminalControl/TermControl.cpp#L3386-L3404 but instead of a "control-relative position", use `CoreWindow::GetForCurrentThread().PointerPosition()`. That's my thought at least.
Author
Owner

@michalnpl commented on GitHub (May 25, 2023):

@zadjii-msft No worries. I thought about it but abandoned the idea because it seems like this should be handled correctly by XAML, and I am also afraid I'll miss some edge cases, or it will not be future-proof if I handle it manually. The proposed code seems to be doing the correct thing but the framework is acting unexpectedly. Perhaps there is a way to have the XAML team look at this?

@michalnpl commented on GitHub (May 25, 2023): @zadjii-msft No worries. I thought about it but abandoned the idea because it seems like this should be handled correctly by XAML, and I am also afraid I'll miss some edge cases, or it will not be future-proof if I handle it manually. The proposed code seems to be doing the correct thing but the framework is acting unexpectedly. Perhaps there is a way to have the XAML team look at this?
Author
Owner

@jamespack commented on GitHub (Jul 8, 2023):

I may take a stab at this if nobody is working it.

@jamespack commented on GitHub (Jul 8, 2023): I may take a stab at this if nobody is working it.
Author
Owner

@jamespack commented on GitHub (Jul 8, 2023):

image image

Which alignment do we want? I can show screenshots of all of them if you'd want to see them all

@jamespack commented on GitHub (Jul 8, 2023): <img width="345" alt="image" src="https://github.com/microsoft/terminal/assets/2086722/05f648d7-ab99-49b1-9b75-3a5b0d0f11e2"> <img width="566" alt="image" src="https://github.com/microsoft/terminal/assets/2086722/200fd884-5bc6-49e7-9207-b7a57e43bf88"> Which alignment do we want? I can show screenshots of all of them if you'd want to see them all
Author
Owner

@jamespack commented on GitHub (Jul 8, 2023):

I kinda like this one.

image
@jamespack commented on GitHub (Jul 8, 2023): I kinda like this one. <img width="424" alt="image" src="https://github.com/microsoft/terminal/assets/2086722/5ad8584c-1803-430e-93b0-04b9f4f5cd8f">
Author
Owner

@jamespack commented on GitHub (Jul 8, 2023):

Do we have a preference on which Icon we use for the LUA shield?
image

@jamespack commented on GitHub (Jul 8, 2023): Do we have a preference on which Icon we use for the LUA shield? <img width="360" alt="image" src="https://github.com/microsoft/terminal/assets/2086722/e527a2a4-55b9-41bf-a695-256a51d5112d">
Author
Owner

@jamespack commented on GitHub (Jul 8, 2023):

Or this guy?

image
@jamespack commented on GitHub (Jul 8, 2023): Or this guy? <img width="382" alt="image" src="https://github.com/microsoft/terminal/assets/2086722/25e5dac9-09b2-4f4d-a2d4-9d0e73d87d51">
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19034