microsoft / WindowsAppSDK

The Windows App SDK empowers all Windows desktop apps with modern Windows UI, APIs, and platform features, including back-compat support, shipped via NuGet.
https://docs.microsoft.com/windows/apps/windows-app-sdk/
MIT License
3.78k stars 319 forks source link

Support TaskbarManager (pinning to taskbar) from desktop apps #1648

Open andrewleader opened 2 years ago

andrewleader commented 2 years ago

Summary

TaskbarManager API is supported in UWP apps but not desktop apps (the API doesn't have a way to pass through your HWND so it's non-functional in desktop apps). The API is used to pin your primary tile to the taskbar, along with pinning secondary tiles to taskbar (the secondary tiles are a limited access feature that we typically instead recommend using Hosted Apps for, but the primary tile pinning is a slightly more popular API).

riverar commented 2 years ago

Scope

Capability Priority
Desktop application can pin to Taskbar without any consent dialogs or prompts Should

Microsoft currently does this via Microsoft Edge so it's only fair that other apps get the same capabilities.

JaiganeshKumaran commented 2 years ago

Scope

Capability Priority Desktop application can pin to Taskbar without any consent dialogs or prompts Should Microsoft currently does this via Microsoft Edge so it's only fair that other apps get the same capabilities.

No apps shouldn't pin to the taskbar without any consent dialogs or prompts. Microsoft Edge should also use consent dialog.

riverar commented 2 years ago

@Jaiganeshkumaran I agree with you, but the Edge team isn't willing to make the change so that leaves one option.

ghost1372 commented 2 years ago

In Windows 11, every apps has a progress bar in taskbar, I hope we can handle it (Like what VS Installer does) Untitled

andrewleader commented 2 years ago

Hi @ghost1372, progress bars are a separate topic and not supported in this UWP TaskbarManager API we're discussing. This API only covers pinning to taskbar.

However, progress bars are already supported by desktop apps: https://docs.microsoft.com/windows/win32/shell/taskbar-extensions#progress-bars

JaiganeshKumaran commented 2 years ago

@Jaiganeshkumaran I agree with you, but the Edge team isn't willing to make the change so that leaves one option.

Then send feedback to them. Because Edge is doing something bad doesn't mean other apps should do the same too.

Gaoyifei1011 commented 1 year ago

Recently, the official blog of Microsoft announced a new api for pinned application to the taskbar. Will this api be put into winrt or wasdk? When will the api be announced?

HO-COOH commented 9 months ago

Till this day, the documentation mentioned nowhere about this can only be used with UWP and cannot be used by a winui3 app, wasting everyone's time trying it then get the exception

castorix commented 9 months ago

MS added some samples in the SDK : https://github.com/microsoft/windows-classic-samples/tree/main/Samples/TaskbarManager But I could not make them work on my Windows 10 OS.

HO-COOH commented 9 months ago

MS added some samples in the SDK : https://github.com/microsoft/windows-classic-samples/tree/main/Samples/TaskbarManager But I could not make them work on my Windows 10 OS.

I tried just that. There are 2 things to confirm:

riverar commented 9 months ago

I wrote up how to generate your own tokens a few years ago (https://withinrafael.com/2021/01/04/generating-valid-tokens-to-access-limited-access-features-in-windows-10/).

You're welcome to use my token generator at https://withinrafael.com/api/windows_laf_token while it is online. (Feature list is current as of Windows vNext 25997. No SLA.)

Gaoyifei1011 commented 9 months ago

These are some of my efforts to add fixed apps to the taskbar in desktop apps 这个是我尝试在桌面应用中添加固定应用到任务栏做出的一些努力 image

This operation according to the ms official documentation prompts, you need to try to unlock the used method. 这个操作根据ms官方的文档提示,需要尝试对使用的方法进行解锁 https://learn.microsoft.com/en-us/windows/apps/design/shell/pin-to-taskbar

This code corresponds to the method that is fixed to be applied to the taskbar call 这一段代码对应的是固定应用到任务栏调用的方法 https://github.com/Gaoyifei1011/GetStoreApp/blob/master/GetStoreApp/Views/Pages/AboutPage.xaml.cs image

Helper class that needs to be unlocked for calling methods 需要对调用方法解锁时的辅助类 https://github.com/Gaoyifei1011/GetStoreApp/blob/master/GetStoreApp/Helpers/Root/FeatureAccessHelper.cs https://github.com/Gaoyifei1011/GetStoreApp/blob/master/GetStoreApp/Helpers/Root/HashAlgorithmHelper.cs

In my own tests, it seems that desktop apps currently only support fixing the current application to the taskbar, not other applications to the taskbar 经过我个人的多次测试,桌面应用目前好像仅支持固定当前应用到任务栏,不支持固定其他应用到任务栏

Equivalent to support only https://learn.microsoft.com/zh-cn/uwp/api/windows.ui.shell.taskbarmanager.requestpincurrentappasync?view=winrt-22621#win Dows - UI - the shell - taskbarmanager - requestpincurrentappasync API, https://learn.microsoft.com/zh-cn/uwp/api/windows.ui.shell.taskbarmanager.requestpinapplistentryasync?view=winrt-22621#w Windows - the UI - the shell - taskbarmanager - requestpinapplistentryasync (Windows - applicationmodel - core - applistentry) can only to the current application AUMID 相当于仅支持 https://learn.microsoft.com/zh-cn/uwp/api/windows.ui.shell.taskbarmanager.requestpincurrentappasync?view=winrt-22621#windows-ui-shell-taskbarmanager-requestpincurrentappasync API,https://learn.microsoft.com/zh-cn/uwp/api/windows.ui.shell.taskbarmanager.requestpinapplistentryasync?view=winrt-22621#windows-ui-shell-taskbarmanager-requestpinapplistentryasync(windows-applicationmodel-core-applistentry) 仅能传入当前应用的AUMID

When fixing other applications, Will happen to other application AUMID [System. UnauthorizedAccessException] (https://blog.csdn.net/Ly_LittleStar/article/details/123378456) 固定其他应用时,传入其他应用的AUMID会发生[System.UnauthorizedAccessException](https://blog.csdn.net/Ly_LittleStar/article/details/123378456)异常

So my personal guess is that ms has added some restrictions to the dll fixed to the taskbar call, and I don't know if such restrictions can be lifted in the future 所以我个人猜测,ms还是在固定应用到任务栏调用的dll中添加了一些限制,不知道这样的限制未来能否解除

Gaoyifei1011 commented 9 months ago

In Windows 11, every apps has a progress bar in taskbar, I hope we can handle it (Like what VS Installer does) Untitled

Personally, I think it's a shame that this API wasn't added to WINRT, and it can only be done by calling the Win32 API in desktop applications 就我个人而言,我觉得这个API没有添加到WINRT中的确是一种遗憾,目前也只能在桌面应用中调用Win32 API来实现这一功能