如何将窗口锁定到屏幕的一部分,并且当我单击下面的窗口时它不会消失?

如何将窗口锁定到屏幕的一部分,并且当我单击下面的窗口时它不会消失?

有没有办法将窗口锁定到 Windows 10 屏幕的一部分,并且当我单击下面的窗口时它不会消失?

答案1

有几种方法可以做到这一点。有几个程序可以强制窗口始终位于顶部。您也可以使用自动热键脚本(见下面的链接)。虽然你可以轻松地在 Google 上搜索这些内容,但这是我找到的第一个结果:

https://www.groovypost.com/howto/howto/windows-programs-always-on-top/

答案2

这使用 Windows 10 中的内置编译器 - 有三个 VB.NET 编译器和三个 C# 编译器 - 只需将每个文本文件复制到同一个文件夹中,然后双击批处理文件即可生成程序。名称是两个文件中的每个文件的第一行。


@Echo Off
Echo TopMost.bat
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 ^
Echo     TopMost Not ^
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

与记事本一起使用

"c:\folder with file\topmost.exe" top Untitled - Notepad

https://winsourcecode.blogspot.com/2019/05/topmostexe-set-window-on-top-or-not.html

相关内容