Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
andrewleader opened this issue Oct 25, 2021 · 13 comments
Open

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

andrewleader opened this issue Oct 25, 2021 · 13 comments

Comments

@andrewleader
Copy link
Contributor

andrewleader commented Oct 25, 2021

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
Copy link
Contributor

riverar commented Oct 26, 2021

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
Copy link
Contributor

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
Copy link
Contributor

riverar commented Oct 26, 2021

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

@ghost1372
Copy link
Contributor

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

@andrewleader
Copy link
Contributor Author

andrewleader commented Oct 27, 2021

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
Copy link
Contributor

@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
Copy link

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
Copy link

HO-COOH commented Nov 26, 2023

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
Copy link

castorix commented Nov 26, 2023

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
Copy link

HO-COOH commented Nov 26, 2023

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:

  • The limited feature access token needs to be accquired from microsoft
  • The line winrt::try_get_activation_factory<winrt::TaskbarManager, winrt::ITaskbarManagerDesktopAppSupportStatics>() seems to return false for desktop app (including winui3 app of course), although not sure if that will return true if the feature is unlocked by the token

@riverar
Copy link
Contributor

riverar commented Nov 26, 2023

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
Copy link

Gaoyifei1011 commented Nov 27, 2023

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://learn.microsoft.com/zh-cn/dotnet/api/system.unauthorizedaccessexception?view=net-7.0)异常

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
Copy link

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来实现这一功能

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants