question

OKP avatar image
0 Votes"
OKP asked NicoZhu-MSFT commented

Can I make UWP app not gain focus after Launching

Can I make UWP app not gain focus after Launching?

windows-uwp
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.

1 Answer

Castorix31 avatar image
1 Vote"
Castorix31 answered NicoZhu-MSFT commented

On Windows 10 >= 1803, you can add for example a Page_Loaded event with

     private async void Page_Loaded(object sender, RoutedEventArgs e)
     {
         IList<AppDiagnosticInfo> adi = await AppDiagnosticInfo.RequestInfoForAppAsync();
         IList<AppResourceGroupInfo> argi = adi[0].GetResourceGroups();
         await argi[0].StartSuspendAsync();
     }
· 4
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 Castorix31 . This would minimize or suspend the app. My scenario is like app should be like overlay or Topmost , But focus should not be there .

0 Votes 0 ·

Well, It looks there is no such api could implement this feature, can you tell us why you want to implement this?

0 Votes 0 ·

I did not find a way either to do it in UWP,
while it is easy in WPF, with WS_EX_NOACTIVATE and HWND_TOPMOST :


136347-wpf-noactivate.gif


0 Votes 0 ·
wpf-noactivate.gif (578.6 KiB)

I have to say it is impossible in pure uwp app, you may try use desktop-bridge to approach.

0 Votes 0 ·