there is something more . look and at https://www.autoitscript.com/forum/topic/209363-_systemmetricsparameterstoarray/
; https://www.autoitscript.com/forum/topic/209707-get-size-of-gui/?do=findComment&comment=1513637
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $hGUI = GUICreate("Example", 200, 200, -1, -1, BitOR($WS_SIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX))
Global $DummyMenuEntry = GUICtrlCreateMenu("DummyMenuEntry", -1, $hGUI)
GUIRegisterMsg($WM_SIZE, 'WM_SIZE')
GUISetState(@SW_SHOW, $hGUI)
While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
GUIDelete($hGUI)
Func WM_SIZE($hWnd, $iMsg, $iWParam, $iLParam)
#forceref $hWnd, $iMsg, $iWParam
Local $iGUIWidth1 = BitAND($iLParam, 0xFFFF)
Local $iGUIHeight1 = BitShift($iLParam, 16)
local $iGUIWidth2 = _WinGetPosAccuracy($hGUI)[2]
local $iGUIHeight2 = _WinGetPosAccuracy($hGUI)[3]
ConsoleWrite("GUIWidth : " & $iGUIWidth1 & " " & $iGUIWidth2 & " " & $iGUIWidth1 - $iGUIWidth2 & @CRLF )
ConsoleWrite("GUIHeight: " & $iGUIHeight1 & " " & $iGUIHeight2 & " " & $iGUIHeight1 - $iGUIHeight2 & @CRLF & @CRLF )
Return ($GUI_RUNDEFMSG)
EndFunc ;==>WM_SIZE
;~ WinGetPos
;~ GUIWidth : 200 216 -16
;~ GUIHeight: 180 239 -59
;~ _WinGetPosAccuracy
;~ GUIWidth : 200 202 -2
;~ GUIHeight: 180 232 -52
Func _WinGetPosAccuracy($hWnd)
Local $HWPos[4] ; [0]=X [1]=Y [2]=Width [3]=Height
If WinExists($hWnd) Then
$HWPos[0] = _WindowDWMX($hWnd)
$HWPos[1] = _WindowDWMY($hWnd)
$HWPos[2] = _WindowDWMWidth($hWnd)
$HWPos[3] = _WindowDWMHeight($hWnd)
Else
Return SetError(1, 0, "")
EndIf
Return $HWPos
EndFunc ;==>_WinGetPosAccuracy
#Region === a short extract from Pal, Peter's AutoIt Library, version 1.25 UDF ===
; https://www.autoitscript.com/forum/topic/201518-pal-peters-autoit-functions-library/
; #FUNCTION# ====================================================================================================================
; Name...........: _WindowDWMWidth
; Description....: Returns window width as registered by the Desktop Window Manager (DWM)
; Syntax.........: _WindowDWMWidth($hGUI)
; Parameters.....: $hGUI - Window GUI handle
; Return values..: Desktop Window Manager window width
; Author.........: Peter Verbeek
; Modified.......:
; ===============================================================================================================================
Func _WindowDWMWidth($hGUI)
; Try finding width by the Desktop Window Manager, Windows Vista and higher
Local $tagRect = "struct;long Left;long Top;long Right;long Bottom;endstruct", $tRect = DllStructCreate($tagRect)
DllCall("Dwmapi.dll", "long", "DwmGetWindowAttribute", "hwnd", WinGetHandle($hGUI), "dword", 9, "ptr", DllStructGetPtr($tRect), "dword", DllStructGetSize($tRect))
If @error = 0 And DllStructGetData($tRect, 3) - DllStructGetData($tRect, 1) > 0 And DllStructGetData($tRect, 4) - DllStructGetData($tRect, 2) > 0 Then Return DllStructGetData($tRect, 3) - DllStructGetData($tRect, 1)
; Alternatively return window width by AutoIt
Local $aWindow = WinGetPos($hGUI)
If @error <> 0 Or $aWindow[0] = -32000 Then Return 0 ; correcting for a minimized window
Return $aWindow[2]
EndFunc ;==>_WindowDWMWidth
; #FUNCTION# ====================================================================================================================
; Name...........: _WindowDWMHeight
; Description....: Returns window height as registered by the Desktop Window Manager (DWM)
; Syntax.........: _WindowDWMHeight($hGUI)
; Parameters.....: $hGUI - Window GUI handle
; Return values..: Desktop Window Manager window height
; Author.........: Peter Verbeek
; Modified.......:
; ===============================================================================================================================
Func _WindowDWMHeight($hGUI)
; Try finding width by the Desktop Window Manager, Windows Vista and higher
Local $tagRect = "struct;long Left;long Top;long Right;long Bottom;endstruct", $tRect = DllStructCreate($tagRect)
DllCall("Dwmapi.dll", "long", "DwmGetWindowAttribute", "hwnd", WinGetHandle($hGUI), "dword", 9, "ptr", DllStructGetPtr($tRect), "dword", DllStructGetSize($tRect))
If @error = 0 And DllStructGetData($tRect, 3) - DllStructGetData($tRect, 1) > 0 And DllStructGetData($tRect, 4) - DllStructGetData($tRect, 2) > 0 Then Return DllStructGetData($tRect, 4) - DllStructGetData($tRect, 2)
; Alternatively return window height by AutoIt
Local $aWindow = WinGetPos($hGUI)
If @error <> 0 Or $aWindow[0] = -32000 Then Return 0 ; correcting for a minimized window
Return $aWindow[3]
EndFunc ;==>_WindowDWMHeight
; #FUNCTION# ====================================================================================================================
; Name...........: _WindowDWMX
; Description....: Returns window x coordinate as registered by the Desktop Window Manager (DWM)
; Syntax.........: _WindowDWMWidth($hGUI)
; Parameters.....: $hGUI - Window GUI handle
; Return values..: Desktop Window Manager window x coordinate
; Author.........: Peter Verbeek
; Modified.......:
; ===============================================================================================================================
Func _WindowDWMX($hGUI)
; Try finding x coordinate by the Desktop Window Manager, Windows Vista and higher
Local $tagRect = "struct;long Left;long Top;long Right;long Bottom;endstruct", $tRect = DllStructCreate($tagRect)
DllCall("Dwmapi.dll", "long", "DwmGetWindowAttribute", "hwnd", WinGetHandle($hGUI), "dword", 9, "ptr", DllStructGetPtr($tRect), "dword", DllStructGetSize($tRect))
If @error = 0 And DllStructGetData($tRect, 3) - DllStructGetData($tRect, 1) > 0 And DllStructGetData($tRect, 4) - DllStructGetData($tRect, 2) > 0 Then Return DllStructGetData($tRect, 1)
; Alternatively return window width by AutoIt
Local $aWindow = WinGetPos($hGUI)
If @error <> 0 Or $aWindow[0] = -32000 Then Return 0 ; correcting for a minimized window
Return $aWindow[0]
EndFunc ;==>_WindowDWMX
; #FUNCTION# ====================================================================================================================
; Name...........: _WindowDWMY
; Description....: Returns window y coordinate as registered by the Desktop Window Manager (DWM)
; Syntax.........: _WindowDWMWidth($hGUI)
; Parameters.....: $hGUI - Window GUI handle
; Return values..: Desktop Window Manager window y coordinate
; Author.........: Peter Verbeek
; Modified.......:
; ===============================================================================================================================
Func _WindowDWMY($hGUI)
; Try finding y coordinate by the Desktop Window Manager, Windows Vista and higher
Local $tagRect = "struct;long Left;long Top;long Right;long Bottom;endstruct", $tRect = DllStructCreate($tagRect)
DllCall("Dwmapi.dll", "long", "DwmGetWindowAttribute", "hwnd", WinGetHandle($hGUI), "dword", 9, "ptr", DllStructGetPtr($tRect), "dword", DllStructGetSize($tRect))
If @error = 0 And DllStructGetData($tRect, 3) - DllStructGetData($tRect, 1) > 0 And DllStructGetData($tRect, 4) - DllStructGetData($tRect, 2) > 0 Then Return DllStructGetData($tRect, 2)
; Alternatively return window width by AutoIt
Local $aWindow = WinGetPos($hGUI)
If @error <> 0 Or $aWindow[0] = -32000 Then Return 0 ; correcting for a minimized window
Return $aWindow[1]
EndFunc ;==>_WindowDWMY
#EndRegion === a short extract from Pal, Peter's AutoIt Library, version 1.25 UDF ===