窗户尺寸

窗户尺寸

如何获取窗口的宽度和高度?假设我(最终用户)在窗口中打开 Chrome,然后调整其大小。我(最终用户)如何才能知道窗口现在有多大?Chrome 只是一个例子;我正在寻找如何在窗口中对任何应用程序执行此操作。

答案1

你可以使用一个简单的工具,例如威斯派或包含在自动热键包裹。

答案2

你可以自己做

将以下两个文件复制到一个文件夹中。

使用

GetWindowRect <Title Of Window>

例如

GetWindowRect Untitled - Notepad

更改/target:exe/target:winexe使其成为非控制台程序

REM GetWindowRect.bat
REM This file compiles GetWindowRect.vb to GetWindowRect.exe
REM GetWindowRect.exe reports on Windows position
REM To use 
REM GetWindowRect 
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc.exe" /target:exe /out:"%~dp0\GetWindowRect.exe" "%~dp0\GetWindowRect.vb"
pause

;GetWindowRect.vb
imports System.Runtime.InteropServices 
Public Module GetWindowRect  

     <StructLayout(LayoutKind.Sequential)> _
    Private Structure RECTL     
        Public Left As UInt32
        Public Top As UInt32
        Public Right As UInt32
        Public Bottom As UInt32
    End Structure

    Private Declare Function GetWindowRect Lib "User32" (ByVal hWnd as IntPtr, ByRef Rect as RectL) as Integer
    Public Declare UNICODE Function FindWindowW Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

    Sub Main
        On Error Resume Next
        Dim hWindows as IntPtr
        Dim Ret as Integer
        hwindows = FindWindowW(vbNullString, Command())
        If hwindows = 0 then
            Msgbox(Command() & " cannot be found.")
        Else
            Dim x as RectL
            Ret = GetWindowRect(hWindows, x)
            If Ret = 0 Then 
                MsgBox("GetWindowRect Error " & Err.LastDllError)
            Else
            'Delete the MsgBox line if using as console program
            Msgbox(x.left & " " & x.top & " " & x.right & " " & x.bottom)
            Console.Writeline(x.left & " " & x.top & " " & x.right & " " & x.bottom)
            End If
        End If
    End Sub

End Module 

也可以在这里找到 -https://winsourcecode.blogspot.com/2020/01/getwindowrectexe-reports-on-windows.html

答案3

使用截图工具捕获窗口的屏幕截图,然后查看屏幕截图的属性以查看窗口的尺寸。

答案4

我最快的方法:

  • Alt+Print Screen
  • 打开油漆并减少画布
  • Ctrl+V

窗口的大小在状态栏中

相关内容