D3fr0s7 Posted December 16, 2022 Share Posted December 16, 2022 I've been searching far and wide for a way to get the title bar size of any active window. What I'm trying to accomplish is moving the mouse to the top left corner of the window (so as to find true window position, relative to screen origin), the corner position where the window borders meet. I'm able to do this for some windows, but other windows do not have the title bar within the client area. So I have to find the title bar size in order to position the mouse where I want it. I've seen suggestions to use _WinAPI_GetSystemMetrics() but it returns a constant, and some windows have a different size title bar than what is returned. Here is a script to work with that outputs to the console what is happening: expandcollapse popup#include <WinAPISysWin.au3> HotKeySet( "{ESC}", "abort") HotKeySet( "{PAUSE}", "_GetWindowCorner") While 1 Sleep( 1000) WEnd Func _GetWindowCorner() Local $aAbsWinPos[2] Local $aDiff[2] ;~ Preserve mouse position. $aMousePos = MouseGetPos() ;~ Get the coordinate of the window. ConsoleWrite( "Window title: " & WinGetTitle( "[ACTIVE]") & @CRLF) $aWinPos = WinGetPos( "[ACTIVE]") ; Get position of active window. ConsoleWrite( "$aWinPos[0]: " & $aWinPos[0] & @CRLF) ConsoleWrite( "$aWinPos[1]: " & $aWinPos[1] & @CRLF) ;~ Record the absolute position of the window. AutoItSetOption( "MouseCoordMode", 2) ; Make mouse coordinate relative to active window client area origin. MouseMove( 0, 0, 0) ; Move mouse to client area origin. Sleep ( 3000) ; Pause to show where the mouse is for troubleshooting. AutoItSetOption( "MouseCoordMode", 1) ; Make mouse positioning relative to screen origin again. $aAbsWinPos = MouseGetPos() ; Record client area origin relative to screen origin. ;~ Get the difference between window client origin and screen origin. ConsoleWrite( "$aAbsWinPos[0]: " & $aAbsWinPos[0] & @CRLF) ConsoleWrite( "$aAbsWinPos[1]: " & $aAbsWinPos[1] & @CRLF) $aDiff[0] = $aWinPos[0] - $aAbsWinPos[0] $aDiff[1] = $aWinPos[1] - $aAbsWinPos[1] ConsoleWrite( "Difference X: " & $aDiff[0] & @CRLF) ConsoleWrite( "Difference Y: " & $aDiff[1] & @CRLF) If Abs($aDiff[0]) > 0 Then $aAbsWinPos[0] -= 1 ; Account for x axis difference, if any. Any difference will be 1, therefore subtract 1. ;If Abs($aDiff[1]) > 0 Then $aAbsWinPos[1] -= _TitleBarSize() ; Account for y axis difference, if any. Difference will be variable, therefore subtract variable. ConsoleWrite( "True Win X: " & $aAbsWinPos[0] & @CRLF) ConsoleWrite( "True Win Y: " & $aAbsWinPos[1] & @CRLF & @CRLF) ;~ Restore mouse position. MouseMove( $aMousePos[0], $aMousePos[1], 0) EndFunc ;===> _GetWindowCorner Func abort() Exit EndFunc ;===> abort As you can see, on line 36, the code is commented out. That is the code that I need to complete, accounting for the title bar size. I can't use it unless I find a way to get the variable title bar size, which is different per window. A good example to see that difference would be to use the window of the autoit script itself, and a notepad window. The notepad's title bar is included in the client area, whereas the Autoit window's title bar is excluded. Func _TitleBarSize() ;~ Code to get variable title bar size... help :c Return $Size EndFunc ;===> _TitleBarSize I need some help making a function to get the title bar size, I appreciate any help or guidance I can get here, I've been at it for a while now :c It helps me to have the window at screen position (0, 0), the code works on notepad because it accounts for the x axis difference as it is always only 1 coordinate point off (I may be wrong). But when it comes to a window like WinRAR or AutoIT, the title bar changes things, and is not always a set value. An example of this discrepancy can be demonstrated by the code when toggled on an AutoIT script, and on the AutoIT compiler program. The compiler has a smaller title bar, excluded from the client area. Thanks in advance! Link to comment Share on other sites More sharing options...
Nine Posted December 16, 2022 Share Posted December 16, 2022 Maybe with _WinAPI_GetClientRect vs _WinAPI_GetWindowRect ? D3fr0s7 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
ioa747 Posted December 16, 2022 Share Posted December 16, 2022 (edited) 2 hours ago, D3fr0s7 said: I've been searching far and wide for a way to get the title bar size of any active window. What I'm trying to accomplish is moving the mouse to the top left corner of the window (so as to find true window position, relative to screen origin), the corner position where the window borders meet. I'm able to do this for some windows, but other windows do not have the title bar within the client area. So I have to find the title bar size in order to position the mouse where I want it. I've seen suggestions to use _WinAPI_GetSystemMetrics() but it returns a constant, and some windows have a different size title bar than what is returned. Here is a script to work with that outputs to the console what is happening: expandcollapse popup#include <WinAPISysWin.au3> HotKeySet( "{ESC}", "abort") HotKeySet( "{PAUSE}", "_GetWindowCorner") While 1 Sleep( 1000) WEnd Func _GetWindowCorner() Local $aAbsWinPos[2] Local $aDiff[2] ;~ Preserve mouse position. $aMousePos = MouseGetPos() ;~ Get the coordinate of the window. ConsoleWrite( "Window title: " & WinGetTitle( "[ACTIVE]") & @CRLF) $aWinPos = WinGetPos( "[ACTIVE]") ; Get position of active window. ConsoleWrite( "$aWinPos[0]: " & $aWinPos[0] & @CRLF) ConsoleWrite( "$aWinPos[1]: " & $aWinPos[1] & @CRLF) ;~ Record the absolute position of the window. AutoItSetOption( "MouseCoordMode", 2) ; Make mouse coordinate relative to active window client area origin. MouseMove( 0, 0, 0) ; Move mouse to client area origin. Sleep ( 3000) ; Pause to show where the mouse is for troubleshooting. AutoItSetOption( "MouseCoordMode", 1) ; Make mouse positioning relative to screen origin again. $aAbsWinPos = MouseGetPos() ; Record client area origin relative to screen origin. ;~ Get the difference between window client origin and screen origin. ConsoleWrite( "$aAbsWinPos[0]: " & $aAbsWinPos[0] & @CRLF) ConsoleWrite( "$aAbsWinPos[1]: " & $aAbsWinPos[1] & @CRLF) $aDiff[0] = $aWinPos[0] - $aAbsWinPos[0] $aDiff[1] = $aWinPos[1] - $aAbsWinPos[1] ConsoleWrite( "Difference X: " & $aDiff[0] & @CRLF) ConsoleWrite( "Difference Y: " & $aDiff[1] & @CRLF) If Abs($aDiff[0]) > 0 Then $aAbsWinPos[0] -= 1 ; Account for x axis difference, if any. Any difference will be 1, therefore subtract 1. ;If Abs($aDiff[1]) > 0 Then $aAbsWinPos[1] -= _TitleBarSize() ; Account for y axis difference, if any. Difference will be variable, therefore subtract variable. ConsoleWrite( "True Win X: " & $aAbsWinPos[0] & @CRLF) ConsoleWrite( "True Win Y: " & $aAbsWinPos[1] & @CRLF & @CRLF) ;~ Restore mouse position. MouseMove( $aMousePos[0], $aMousePos[1], 0) EndFunc ;===> _GetWindowCorner Func abort() Exit EndFunc ;===> abort As you can see, on line 36, the code is commented out. That is the code that I need to complete, accounting for the title bar size. I can't use it unless I find a way to get the variable title bar size, which is different per window. A good example to see that difference would be to use the window of the autoit script itself, and a notepad window. The notepad's title bar is included in the client area, whereas the Autoit window's title bar is excluded. Func _TitleBarSize() ;~ Code to get variable title bar size... help :c Return $Size EndFunc ;===> _TitleBarSize I need some help making a function to get the title bar size, I appreciate any help or guidance I can get here, I've been at it for a while now :c It helps me to have the window at screen position (0, 0), the code works on notepad because it accounts for the x axis difference as it is always only 1 coordinate point off (I may be wrong). But when it comes to a window like WinRAR or AutoIT, the title bar changes things, and is not always a set value. An example of this discrepancy can be demonstrated by the code when toggled on an AutoIT script, and on the AutoIT compiler program. The compiler has a smaller title bar, excluded from the client area. Thanks in advance! Maybe need chance the number I have 1920 X 1080 display Func _TitleBarSize($aWinTitle = "[ACTIVE]") Local $aPos = WinGetPos($aWinTitle) ;$aPos[0] = X position $aPos[1] = Y position $aPos[2] = Width $aPos[3] = Height Local $aBarSize[4] ;$aBarSize[0] = X position $aBarSize[1] = Y position $aBarSize[2] = Width $aBarSize[3] = Height $aBarSize[0] = $aPos[0] + 8 $aBarSize[1] = $aPos[1] + 1 $aBarSize[2] = $aPos[2] - 16 $aBarSize[3] = 31 ConsoleWrite("BarSize: " & $aBarSize[2] & " X " & $aBarSize[3] & @CRLF) ; <<<<<<<<<<<<<< make ghost gui to check $ghost_gui = GUICreate("ghost_gui", $aBarSize[2], $aBarSize[3], $aBarSize[0], $aBarSize[1], $WS_POPUP, $WS_EX_TOPMOST) GUISetBkColor("0xFFFF00") ; $COLOR_YELLOW WinSetTrans($ghost_gui, "", 80) GUISetState(@SW_SHOW, $ghost_gui) ; >>>>>>>>>>>>>>> then delete Return $aBarSize EndFunc ;==>_TitleBarSize Edited December 16, 2022 by ioa747 D3fr0s7 1 I know that I know nothing Link to comment Share on other sites More sharing options...
D3fr0s7 Posted December 17, 2022 Author Share Posted December 17, 2022 Thank you @Nine, those functions were just what I needed. After a while of playing with it, I finally arrived to some code that will accomplish exactly what I set out to. On 12/15/2022 at 8:36 PM, ioa747 said: Maybe need chance the number I have 1920 X 1080 display Func _TitleBarSize($aWinTitle = "[ACTIVE]") Local $aPos = WinGetPos($aWinTitle) ;$aPos[0] = X position $aPos[1] = Y position $aPos[2] = Width $aPos[3] = Height Local $aBarSize[4] ;$aBarSize[0] = X position $aBarSize[1] = Y position $aBarSize[2] = Width $aBarSize[3] = Height $aBarSize[0] = $aPos[0] + 8 $aBarSize[1] = $aPos[1] + 1 $aBarSize[2] = $aPos[2] - 16 $aBarSize[3] = 31 ConsoleWrite("BarSize: " & $aBarSize[2] & " X " & $aBarSize[3] & @CRLF) ; <<<<<<<<<<<<<< make ghost gui to check $ghost_gui = GUICreate("ghost_gui", $aBarSize[2], $aBarSize[3], $aBarSize[0], $aBarSize[1], $WS_POPUP, $WS_EX_TOPMOST) GUISetBkColor("0xFFFF00") ; $COLOR_YELLOW WinSetTrans($ghost_gui, "", 80) GUISetState(@SW_SHOW, $ghost_gui) ; >>>>>>>>>>>>>>> then delete Return $aBarSize EndFunc ;==>_TitleBarSize Although creating a ghost GUI will have been a solution too, the _WinAPI method is lighter. Thank you for the suggestion though, you were right that I should make the variables take into account the border and frame size difference across different OS's. So I went ahead and did that too, turns out I did need to use _WinAPI_GetSystemMetrics() after all! Link to comment Share on other sites More sharing options...
pixelsearch Posted December 20, 2022 Share Posted December 20, 2022 @D3fr0s7 Let's continue here the discussion started in this post. Could you please run the following script (based on the function you posted in the other thread) then paste here : 1) The 6 informative lines appearing in Scite Console (numbered from 1: to 6:)2) A partial pic (unzoomed, unshrinked) of the NotePad window before you close the script (it should include a part of the title bar + the menu bar + a part of the client area) so we'll able to measure the title bar height (in pixels) based on your pic.3) What is your OS ? (as the title bar height is different depending on the OS) expandcollapse popup#include <WinAPISys.au3> ; Open Notepad Run("notepad.exe") WinWaitActive("[CLASS:Notepad]") Local $hWnd = WinGetHandle("[CLASS:Notepad]") If $hWnd = 0 Then Exit MsgBox(0, "NotePad", "Handle = 0") ; Move NotePad window to 10, 10 and resize it to 500, 400 WinMove($hWnd, "", 10, 10, 500, 400) ConsoleWrite("1: Window Title : " & WinGetTitle($hWnd) & @crlf) Local $iTitleBarHeight = _TitleBarSize($hWnd) ConsoleWrite("6: $iTitleBarHeight : " & $iTitleBarHeight & @crlf) MsgBox(0,"Before the script ends", _ "Please make a screen copy of your NotePad Window" & @crlf & _ "rhen end the script when it's done") ; Close Notepad window WinClose($hWnd) ;========================= Func _TitleBarSize( $hWnd) Static $iFrame = _WinAPI_GetSystemMetrics( 32) ConsoleWrite("2: $iFrame = " & $iFrame & @crlf) Static $iBorder = _WinAPI_GetSystemMetrics( 5) ConsoleWrite("3: $iBorder = " & $iBorder & @crlf) $tWinRect = _WinAPI_GetWindowRect( $hWnd) $tClientRect = _WinAPI_GetClientRect( $hWnd) $iWinHeight = DllStructGetData( $tWinRect, "Bottom") - DllStructGetData( $tWinRect, "Top") ConsoleWrite("4: $iWinHeight = " & $iWinHeight & @crlf) $iClientHeight = DllStructGetData( $tClientRect, "Bottom") - DllStructGetData( $tClientRect, "Top") ConsoleWrite("5: $iClientHeight = " & $iClientHeight & @crlf) $iTitleBarSize = $iWinHeight - $iClientHeight - $iFrame - $iBorder Return $iTitleBarSize EndFunc ;==>_TitleBarSize Thanks Link to comment Share on other sites More sharing options...
D3fr0s7 Posted December 20, 2022 Author Share Posted December 20, 2022 @pixelsearch Okay as soon as I ran the code it was obviously false to me. Here is the console output you wanted anyway: 1: Window Title : Untitled - Notepad 2: $iFrame = 8 3: $iBorder = 1 4: $iWinHeight = 400 5: $iClientHeight = 394 6: $iTitleBarHeight : -3 I went to the other function I created to see if it was working properly and it is not (I didn't think to test it on notepad... lol). Now I'm invested in trying to solve this issue. The client and window rectangles for notepad are displayed below. Client in blue, window in red: The frame size is obviously wrong. All window clients have a border so _WinAPI_GetSystemMetrics( 5) is required (5 corresponds to the size of window border, in my case 1px). Taking the border into consideration, the size of the space between the client border and the window looks to be 4px. When I run _WinAPI_GetSystemMetrics() in a loop to find what values could correspond to that, I get 5 numbers: 36, 37, 68, 69, and 85. Constants for these numbers with the exception of 85 tell us that what they refer to are $SM_CXDOUBLECLK, $SM_CYDOUBLECLK, $SM_CXDRAG, and $SM_CYDRAG respectively (except 85). There is no information on _WinAPI_GetSystemMetrics( 85), not even the windows API help page has information on it. https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemmetrics However, the number follows the constant for 84 which corresponds to $SM_CYFOCUSBORDER, and 83 which is $SM_CXFOCUSBORDER. I'm not entirely sure but metric 85 could be the metric that corresponds to this notepad's frame size. Any search for system metrics that correspond to values from 5 to 7 return nothing. Meaning that within a margin of error that would make the frame size of the notepad window be anywhere from 5 to 7 (Remember, _WinAPI_GetSystemMetrics( 32) = 8) returns nothing. I feel like there is a strong possibility that metric 85 corresponds to this 4px gap between the border of the client window rectangle and the window rectangle. Link to comment Share on other sites More sharing options...
pixelsearch Posted December 20, 2022 Share Posted December 20, 2022 Thanks for your output. Is the "title bar height" returned by the following script more accurate ? This script is based on the GetTitleBarInfo function : expandcollapse popup#include <WinAPISysWin.au3> Example() Func Example() ; Open Notepad Run("notepad.exe") WinWaitActive("[CLASS:Notepad]") Local $hWnd = WinGetHandle("[CLASS:Notepad]") If $hWnd = 0 Then Exit MsgBox(0, "NotePad", "Handle = 0") ; Move NotePad window to 10, 10 and resize it to 500, 400 WinMove($hWnd, "", 10, 10, 500, 400) Local $tTITLEBARINFO = _WinAPI_GetTitleBarInfo($hWnd) ConsoleWrite("TitleBar Coords : Left & Top & Right & Bottom : " & _ $tTITLEBARINFO.TitleBar(1) & " / " & $tTITLEBARINFO.TitleBar(2) & " / " & _ $tTITLEBARINFO.TitleBar(3) & " / " & $tTITLEBARINFO.TitleBar(4) & @crlf) ConsoleWrite("TitleBar Height : Bottom - Top + 1 = " & _ ($tTITLEBARINFO.TitleBar(4) - $tTITLEBARINFO.TitleBar(2) + 1) & @crlf) ; For $i = 1 To 6 ; ConsoleWrite("Element " & $i & " : 0x" & Hex($tTITLEBARINFO.State(($i)), 8) & @crlf) ; Next EndFunc ;==>Example ;================================== Func _WinAPI_GetTitleBarInfo($hWnd) Local Const $CCHILDREN_TITLEBAR = 5 Local Const $tagTITLEBARINFO = 'dword Size;long TitleBar[4];dword State[' & ($CCHILDREN_TITLEBAR + 1 ) & ']' Local $tTITLEBARINFO = DllStructCreate($tagTITLEBARINFO) DllStructSetData($tTITLEBARINFO, 'Size', DllStructGetSize($tTITLEBARINFO)) Local $aCall = DllCall('user32.dll', 'bool', 'GetTitleBarInfo', 'hwnd', $hWnd, 'struct*', $tTITLEBARINFO) If @error Or Not $aCall[0] Then Return SetError(@error + 10, @extended, 0) Return $tTITLEBARINFO EndFunc ;==>_WinAPI_GetTitleBarInfo Link to comment Share on other sites More sharing options...
ioa747 Posted December 20, 2022 Share Posted December 20, 2022 (edited) @pixelsearch 😕 for me is : OS:WIN_10/2009 CPU:X64 OS:X64 Display:1920X1080 Scale:100% 1: Window Title : Untitled - Notepad 2: $iFrame = 8 3: $iBorder = 1 4: $iWinHeight = 400 5: $iClientHeight = 341 6: $iTitleBarHeight : 50 Edited December 20, 2022 by ioa747 I know that I know nothing Link to comment Share on other sites More sharing options...
D3fr0s7 Posted December 20, 2022 Author Share Posted December 20, 2022 (edited) @pixelsearch It returns 24 for me, which seems smaller than it should be, but definitely better than -3. I'm surprised to see ioa747's title bar height at 50, still incorrect but not -3. Edit: Actually I'm not sure if title bar height of 50 is incorrect for windows 10. OS: x64 Win_11/2021 CPU: x64 Display: 3840x1600 100% scaling Edited December 20, 2022 by D3fr0s7 Link to comment Share on other sites More sharing options...
ioa747 Posted December 20, 2022 Share Posted December 20, 2022 50 is along with the menu https://i.imgur.com/PwJFOuH.png I know that I know nothing Link to comment Share on other sites More sharing options...
ioa747 Posted December 20, 2022 Share Posted December 20, 2022 D3fr0s7 I found your function here and i tried it expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISys.au3> Example() ;---------------------------------------------------------------------------------------- Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("AutoIt", 400, 400, 1, 1) GUISetState(@SW_SHOW, $hGUI) _WinInfo($hGUI) ; Open Notepad Run("notepad.exe") WinWaitActive("[CLASS:Notepad]") Local $hWnd = WinGetHandle("[CLASS:Notepad]") If $hWnd = 0 Then Exit MsgBox(0, "NotePad", "Handle = 0") ; Move NotePad window to 10, 10 and resize it to 500, 400 WinMove($hWnd, "", 1, 1, 400, 400) _WinInfo($hWnd) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example ;---------------------------------------------------------------------------------------- Func _WinInfo($hWnd) Local $wTitle = WinGetTitle($hWnd) ConsoleWrite("-------------------------------------" & @CRLF) ConsoleWrite('Window Ttitle = ' & $wTitle & @CRLF & @CRLF) Local $aWindow_Size = WinGetPos($hWnd) ConsoleWrite('Window X Ppos = ' & $aWindow_Size[0] & @CRLF) ConsoleWrite('Window Y Ppos = ' & $aWindow_Size[1] & @CRLF) ConsoleWrite('Window Width = ' & $aWindow_Size[2] & @CRLF) ConsoleWrite('Window Height = ' & $aWindow_Size[3] & @CRLF) Local $aWindowClientArea_Size = WinGetClientSize($hWnd) ConsoleWrite('Window Client Area Width = ' & $aWindowClientArea_Size[0] & @CRLF) ConsoleWrite('Window Client Area Height = ' & $aWindowClientArea_Size[1]& @CRLF) ConsoleWrite('TitleBarSize = ' & _TitleBarSize( $hWnd) & @CRLF & @CRLF) EndFunc ;---------------------------------------------------------------------------------------- Func _TitleBarSize( $hWnd) Static $iFrame = _WinAPI_GetSystemMetrics( 32) Static $iBorder = _WinAPI_GetSystemMetrics( 5) $tWinRect = _WinAPI_GetWindowRect( $hWnd) $tClientRect = _WinAPI_GetClientRect( $hWnd) $iWinHeight = DllStructGetData( $tWinRect, "Bottom") - DllStructGetData( $tWinRect, "Top") $iClientHeight = DllStructGetData( $tClientRect, "Bottom") - DllStructGetData( $tClientRect, "Top") $iTitleBarSize = $iWinHeight - $iClientHeight - $iFrame - $iBorder Return $iTitleBarSize EndFunc ;==>_TitleBarSize ;---------------------------------------------------------------------------------------- Console output: ------------------------------------- Window Ttitle = AutoIt Window X Ppos = 1 Window Y Ppos = 1 Window Width = 406 Window Height = 429 Window Client Area Width = 400 Window Client Area Height = 400 TitleBarSize = 20 ------------------------------------- Window Ttitle = Untitled - Notepad Window X Ppos = 1 Window Y Ppos = 1 Window Width = 400 Window Height = 400 Window Client Area Width = 384 Window Client Area Height = 341 TitleBarSize = 50 still title bar height at 50 what struck me though is that the window doesn't go to the left by 1 pixel in the X coordinate (unrelated to your function) photo result: I know that I know nothing Link to comment Share on other sites More sharing options...
pixelsearch Posted December 20, 2022 Share Posted December 20, 2022 (edited) 4 hours ago, ioa747 said: 50 is along with the menu That was my conclusion too, as I'm getting nearly the same values as ioa747, so the GetTitleBarInfo function seems to do a great job on our 3 computers (we're getting the same title height when using this function, which excludes the Menu bar height) Now why D3fr0s7 got a $iWinHeight nearly the same as $iClientHeight ? That's a mystery, maybe it's related to Windows 11 ? Thanks to both of you for the tests and good luck. Edit @ioa747 I'm downloading your interesting imgur pic (NotePad with a grid, including title bar & menu bar & client area) because it will surely be useful again one day, as imgur deletes pics sooner or later. Also the "yellow ghost transparent title" found in one of your preceding script was interesting too. Edited December 20, 2022 by pixelsearch Link to comment Share on other sites More sharing options...
D3fr0s7 Posted December 20, 2022 Author Share Posted December 20, 2022 (edited) I'm curious to know what _WinAPI_GetSystemMetrics( 85) returns for you. Could you let me know? I'm still trying to correct this issue for my own script. #include <WinAPISys.au3> _ReadMetric() Func _ReadMetric() ConsoleWrite( "Metric 85: " & _WinAPI_GetSystemMetrics( 85) & @CRLF) EndFunc If you wouldn't mind helping 🥺 @ioa747 @pixelsearch Edited December 20, 2022 by D3fr0s7 Link to comment Share on other sites More sharing options...
ioa747 Posted December 20, 2022 Share Posted December 20, 2022 4 minutes ago, D3fr0s7 said: I'm curious to know what _WinAPI_GetSystemMetrics( 85) returns for you. Could you let me know? I'm still trying to correct this issue for my own script. #include <WinAPISys.au3> _ReadMetric() Func _ReadMetric() ConsoleWrite( "Metric 85: " & _WinAPI_GetSystemMetrics( 85) & @CRLF) EndFunc If you wouldn't mind helping 🥺 @ioa747 @pixelsearch Metric 85: 4 D3fr0s7 1 I know that I know nothing Link to comment Share on other sites More sharing options...
pixelsearch Posted December 20, 2022 Share Posted December 20, 2022 @D3fr0s7 On my antique computer (Windows XP, 96DPI) then the undocumented _WinAPI_GetSystemMetrics(85) returns 0 If it can help you, I found a webpage (french) where a guy displays twice all results of his GetSystemMetrics including (85) . Here is the link and here is a partial output of the webpage : ... getsystemmetrics (83) 1 getsystemmetrics (84) 1 getsystemmetrics (85) 4 getsystemmetrics (86) 0 getsystemmetrics (87) 1 ... So the assumption you made in one of your preceding script seems correct, when compared to his output. 10 hours ago, D3fr0s7 said: I feel like there is a strong possibility that metric 85 corresponds to this 4px gap between the border of the client window rectangle and the window rectangle. Link to comment Share on other sites More sharing options...
D3fr0s7 Posted December 20, 2022 Author Share Posted December 20, 2022 (edited) Okay well I was able to fix my script but I did so without having to get the title bar height. It's bothersome though. When you use AutoIt Window Info on the notepad, it shows that the title bar is 32px and the menu bar is 40px. However, no _GetSystemMetrics() value corresponds correctly to the 32px title bar, and none for the 40px menu bar. The text input starts at 72px from client origin. so the 32px title bar and 40px menu bar fit in above it. _WinAPI_GetSystemMetrics( 4) which corresponds to $SM_CYCAPTION ( title bar) returns 24px and that is inapplicable. Maybe there is a way to grab the position of an element of a GUI that is 24px to 80px from the window origin, and then subtract that position Y value from the client area height in order to get the title bar size? I've been trying to grab the UI elements to do so but I'm a novice when it comes to this type of manipulation. I've been at it for a while. Should we make a new thread? As this one is solved and I don't know how to mark it as not solved. Edited December 20, 2022 by D3fr0s7 Found out how to mark it as not solved Link to comment Share on other sites More sharing options...
ioa747 Posted December 22, 2022 Share Posted December 22, 2022 something relative And i found hear similar functions Great collection ; _WindowWidth Window Returns window width, client size + border ; _WindowHeight Window Returns window height, client size + border ; _WindowDWMWidth Window Returns width of window as registered by the Desktop Window Manager (DWM), Windows Vista and higher ; _WindowDWMHeight Window Returns height of window as registered by the Desktop Window Manager (DWM), Windows Vista and higher ; _WindowClientWidth Window Returns width of window client area ; _WindowClientHeight Window Returns height of window client area ; _WindowBordersWidth Window Returns total width of window borders ; _WindowBordersHeight Window Returns total height of window borders ; _WindowMenuHeight Window Returns height of menu bar ; _WindowGetX Window Returns x position of window on screen ; _WindowGetY Window Returns y position of window on screen ; _WindowDWMX Window Returns x coordinate of window as registered by the Desktop Window Manager (DWM), Windows Vista and higher ; _WindowDWMY especially to the 'window, desktop and monitor' section I know that I know nothing Link to comment Share on other sites More sharing options...
D3fr0s7 Posted December 22, 2022 Author Share Posted December 22, 2022 @ioa747 Thank you for sharing, that is a very interesting collection of functions! I found the DWM functions particularly interesting and I might employ them instead of what I'm using as they seem lighter, calling on a DLL rather than doing math to find the values those return! However, I still am not able to find title bar height as that is variable per window, and most functions I've been able to find only return a constant. I'm currently trying to figure out how to access a function from a DLL file so that I can utilize "GetTitleBarInfo" in the "user32.dll" in order to hopefully find a way to solve this issue of not being able to get the title bar size. Here is the thread I've opened to help get to that end: Jump over to that thread if you'd like to maybe help with that! I'm not that experienced with DLLs but I'm looking into them. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now