我知道在互联网上和这个网站上都有很多答案,但是它们都不适用于我,因为所有答案都涉及安装某种软件。
我想要一个解决方案,让 Windows 始终位于顶部,而无需安装任何东西。操作系统是 Windows10。这是 Windows 所缺乏的功能,所以我想会有很多广告软件和恶意软件被创建来解决这个问题。因此,我犹豫是否要安装任何在网上找到的与此相关的可执行程序。下载某种脚本或源代码,然后我自己可以从中构建可执行文件将是一个理想的解决方案。
答案1
来自我的存储库https://winsourcecode.blogspot.com/2019/05/topmostexe-set-window-on-top-or-not.html
将两个文本文件复制到同一个文件夹。它们的名称位于两个文件的第一行。双击批处理文件以构建它。
TopMost.exe 是否将窗口置于顶部
Echo TopMost.bat
@Echo Off
Echo This file compiles TopMost.vb to TopMost.exe
Echo TopMost.exe set a window on top or not
Echo To use
Echo TopMost Top ^<windowtitle^>
Echo TopMost Not ^<windowtitle^>
Echo E.G.
Echo TopMost Top Untitled - Notepad
Echo -----------------------------------------------------
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc.exe" /target:winexe /out:"%~dp0\TopMost.exe" "%~dp0\TopMost.vb"
pause
'TopMost.vb
Imports System
Imports System.IO
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Public Module TopMost
Public Declare UNICODE Function FindWindowW Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As IntPtr, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
Public Const HWND_TOPMOST = -1
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const HWND_NOTOPMOST = -2
Sub Main()
On Error Resume Next
Dim hWindows as IntPtr
Dim CmdLine as String
Dim Ret as Integer
CmdLine = Mid(Command(),5)
hwindows = FindWindowW(vbNullString, CmdLine)
If hwindows = 0 then
Msgbox(Cmdline & " cannot be found.")
Else
If LCase(Left(Command(), 3)) = LCase("Top") then
Ret = SetWindowPos(hwindows, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE)
If Ret = 0 Then MsgBox("Set Pos Error is " & Err.LastDllError)
ElseIf LCase(Left(Command(), 3)) = LCase("Not") then
Ret = SetWindowPos(hwindows, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE)
If Ret = 0 Then MsgBox("Set Pos Error is " & Err.LastDllError)
Else
Msgbox("Command line not recognised")
End If
End If
End Sub
End Module