I have a recording program that stays TopMost
all the time except when I open a Modern app (Windows 8)
or the Start Screen
.
It is possible to make a desktop application stay on top of modern apps, like the Magnifying Glass
tool:
Now, the problem is that using the TopMost option and/or the API call in a WPF window won't work with modern apps.
static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
static readonly IntPtr HWND_TOP = new IntPtr(0);
static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
const UInt32 SWP_NOSIZE = 0x0001;
const UInt32 SWP_NOMOVE = 0x0002;
const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
//OnLoaded event handler:
var source = PresentationSource.FromVisual(this) as HwndSource;
SetWindowPos(source.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
Most Popular Apps 2021 (Global)TikTok retained its spot as the most downloaded app in 2021, although total downloads decreased by 194 million in 2021. Facebook had three apps in the top five.
Only applications marked as Accessibility related can do this. To achieve it, follow these guidelines (taken from the comments section of this article):
- The application must demand uiAccess (app.manifest)
- The application must assert “topmost” window positioning (either in Win32/SetWindowPos or WinForms/WPF’s “Topmost” property, programmatically or otherwise)
- Without making changes to the group policy setting, it must be installed to some trusted location [C:\Windows, C:\Program Files, C:\Program Files (x86)]. a. Note: If you want to be able to run it out of an arbitrary location, you must disable the security setting: “User Account Control: Only elevate UIAccess applications that are installed in secure locations”. b. Note2: This is the same as setting HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\ValidateAdminCodeSignatures to 0
- Said application cannot be ran in the debugger
- If it’s a .NET application a. The manifest must be embedded in a post-build step b. The application must have “delayed signing” (meaning it cannot be ran from the built-in debugger, although you can build and attach – this is what Microsoft does)
- The application must be signed with a trusted certificate.
- Said trusted certificate must be installed to the Trusted Root Certificate Authority (this is important! It must not just simply installed) For more info see: http://msdn.microsoft.com/en-us/library/ms726294
... Not really a trivial task!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With