窗戶尺寸

窗戶尺寸

如何取得視窗的寬度和高度?假設我(一名最終用戶)在視窗中開啟 Chrome,然後調整其大小。作為最終用戶,我如何知道窗口現在有多大? Chrome 只是一個例子;我正在尋找如何在視窗中的任何應用程式中執行此操作。

答案1

您可以使用一個簡單的工具,例如WinSpy或 Window Spy 工具包含在自動熱鍵包裹。

答案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
  • 打開paint並縮小Canvas
  • Ctrl+V

視窗大小在狀態列中

相關內容