-1

I tried this script :

https://github.com/bkfarnsworth/Always-On-Top-PS-Script

It listed all apps successfully, but I doens't seem to actually make a window on top (I selected a notepad window).

user310291
  • 36,946
  • 82
  • 271
  • 487

1 Answers1

3

FYI there exists a standard Always on Top utility in Microsoft PowerToys that can do this.
Anyways, if you need to automate this, you can do this from PowerShell using the SetWindowPos function (winuser.h) where the second argument (-1) stands for TOPMOST:

$User32 = Add-Type -Debug:$False -MemberDefinition '
    [DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X,int Y, int cx, int cy, uint uFlags);
' -Name "User32Functions" -namespace User32Functions -PassThru

$Handle = (Get-Process -Name notepad).MainWindowHandle
[Void]$User32::SetWindowPos($Handle, -1, 0, 0, 0, 0, 0x53)
iRon
  • 20,463
  • 10
  • 53
  • 79
  • an app is not a script you can customize and ingrate with other scripts. It's weird you don't know this : if I wanted an app I would have asked SuperUser Forum instead ;) – user310291 Aug 12 '22 at 06:58
  • @use Why do you expect an answer? As it stands, you haven't even asked a question. Maybe it's time for you to take the [tour] in addition to reading [ask]. – IInspectable Aug 12 '22 at 10:42