Nemcija Posted January 8, 2010 Share Posted January 8, 2010 Hi, Does anyone know a way to get the position and size of the working space of a window, independent of the style of the window. I've got a screenshot here, the area i'm talking about i've marked red. Thank you for your ideas Nem [url=www.vergessene-welt.de][/url] Link to comment Share on other sites More sharing options...
Mat Posted January 8, 2010 Share Posted January 8, 2010 You want the client rectangle. WinApi.au3 has 3 functions that you may want: _WinAPI_GetClientRect _WinAPI_GetClientHeight _WinAPI_GetClientWidth example: (taken from the helpfile entry for "_WinAPI_GetClientRect") Opt('MustDeclareVars', 1) #include <WinAPI.au3> _Main() Func _Main() Local $hwnd, $tRect $hwnd = GUICreate("test") $tRect = _WinAPI_GetClientRect($hwnd) MsgBox(4096, "Rect", _ "Left..: " & DllStructGetData($tRect, "Left") & @LF & _ "Right.: " & DllStructGetData($tRect, "Right") & @LF & _ "Top...: " & DllStructGetData($tRect, "Top") & @LF & _ "Bottom: " & DllStructGetData($tRect, "Bottom")) EndFunc ;==>_Main Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
Nemcija Posted January 9, 2010 Author Share Posted January 9, 2010 This doesn't solve the problem completely, maybe i've forgotten to tell you that I need the absolute position on screen, not relative to the window. This returns Left: 0 Right: 400 Top: 0 Bottom: 400 So its very similar to WinGetClientSize ( ) But for example the window is in the middle of my screen it should be Left: 0 + x Right: 400 + x Top: 0 + y Bottom: 400 + y I can't take the information vom WinGetPos ( ) because this includes the border and the titlebar. Nem [url=www.vergessene-welt.de][/url] Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted January 9, 2010 Share Posted January 9, 2010 Try _WinAPI_ClientToScreen() .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Nemcija Posted January 9, 2010 Author Share Posted January 9, 2010 (edited) Okay, I've got a solution for myself. Don't know whether its always working correctly, or maybe there is an easier way ... But it does what I need expandcollapse popup#include <WinAPI.au3> $hwnd = GUICreate("test",100,150,5,200) $rect = _WinAPI_GetClientScreenRect($hwnd) If IsArray($rect) Then MsgBox(0, "_WinAPI_GetClientScreenRect Example", _ "Left: " & $rect[0] & @CRLF & _ "Right: " & $rect[1] & @CRLF & _ "Top: " & $rect[2] & @CRLF & _ "Bottom: " & $rect[3]) Else MsgBox(0,"Failed","Failed") EndIf ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_GetClientScreenRect ; Description ...: Returns the onscreen rect of a window. ; Syntax.........: _WinAPI_GetClientScreenRect($hWindow) ; Parameters ....: $hWindow - Identifies an open handle to a window ; Return values .: Success - Array ; [0] Left ; [1] Right ; [2] Top ; [3] Bottom ; Failure - False ; Author ........: Nemcija ; Remarks .......: For minimized windows values wouldn't be correct! ; Related .......: _WinAPI_GetClientRect ; Example .......: ;~ $hwnd = GUICreate("test",100,150,5,200) ;~ $rect = _WinAPI_GetClientScreenRect($hwnd) ;~ If IsArray($rect) Then ;~ MsgBox(0, "_WinAPI_GetClientScreenRect Example", _ ;~ "Left: " & $rect[0] & @CRLF & _ ;~ "Right: " & $rect[1] & @CRLF & _ ;~ "Top: " & $rect[2] & @CRLF & _ ;~ "Bottom: " & $rect[3]) ;~ Else ;~ MsgBox(0,"Failed","Failed") ;~ EndIf ; =============================================================================================================================== Func _WinAPI_GetClientScreenRect($hWindow) Local $tLocalClientRect, $tPoint, $aiReturnValue[4] $tLocalClientRect = _WinAPI_GetClientRect($hWindow) if @error Then Return SetError(@error, @extended, False) $tPoint = DllStructCreate("int X;int Y") DllStructSetData($tPoint, "X", DllStructGetData($tLocalClientRect, "Left")) DllStructSetData($tPoint, "Y", DllStructGetData($tLocalClientRect, "Top")) _WinAPI_ClientToScreen($hWindow, $tPoint) if @error Then Return SetError(@error, @extended, False) $aiReturnValue[0] = DllStructGetData($tPoint, "X") $aiReturnValue[1] = $aiReturnValue[0] + DllStructGetData($tLocalClientRect, "Right") $aiReturnValue[2] = DllStructGetData($tPoint, "Y") $aiReturnValue[3] = $aiReturnValue[2] + DllStructGetData($tLocalClientRect, "Bottom") Return $aiReturnValue EndFunc At least it just combines two functions ^^ Maybe its usefull for someone else ... Sorry if it is not named/documented correctly, I'm not familar with this things for autoit ... Thank you for your help! Nem Edited January 9, 2010 by Nemcija [url=www.vergessene-welt.de][/url] 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