Jump to content
Sign in to follow this  

Working area of GUI

Recommended Posts

I thought this would be a simple task but it appears no to be so.

I need to calculate the size and position, either absolute or relative to GUI, the area of a GUI of which is coloured black in the following simple example.

I'm calling it the working area because client area does not fit my description.

I've done a fair bit of looking around the forum and the accepted answers appears to be one of _WinAPI_GetSystemMetrics of the caption bar height and _WinAPI_GetClientRect.

Neither of those suit my purpose.

The area I'm getting encroaches on all borders and GUI title bar.

#include <GUIConstantsEx.au3>
#include <WinAPI.au3>

$hGui = GUICreate("GUI", 400, 400)



Until GUIGetMsg() = -3

Func _GetWorkingArea()
    Local Const $SM_CYCAPTION = 4
    Local Const $SM_CXBORDER = 5
    Local $aWinPos = WinGetPos($hGui)
    Local $iMouseSpeed = 40
    Local $iTitleBarHeight = _WinAPI_GetSystemMetrics($SM_CYCAPTION)
    Local $iBorderWidth = _WinAPI_GetSystemMetrics($SM_CXBORDER)

    Local $tRect = _WinAPI_GetClientRect($hGui)

    MouseMove($aWinPos[0] + $iBorderWidth, $aWinPos[1] + $iTitleBarHeight + $iBorderWidth, $iMouseSpeed)

    MouseMove($aWinPos[0] + $aWinPos[2], $aWinPos[1] + $iTitleBarHeight + $iBorderWidth, $iMouseSpeed)
    MouseMove($aWinPos[0] + $aWinPos[2] - ($iBorderWidth * 2), $aWinPos[1] + $aWinPos[3], $iMouseSpeed)
    MouseMove($aWinPos[0], $aWinPos[1] + $aWinPos[3] - ($iBorderWidth * 2), $iMouseSpeed)
    MouseMove($aWinPos[0] + $iBorderWidth, $aWinPos[1] + $iTitleBarHeight, $iMouseSpeed)

    MsgBox(4096, "Rect", _
            "Left..: " & DllStructGetData($tRect, "Left") & @LF & _
            "Right.: " & DllStructGetData($tRect, "Right") & @LF & _
            "Top...: " & DllStructGetData($tRect, "Top") & @LF & _
            "Bottom: " & DllStructGetData($tRect, "Bottom"))
EndFunc   ;==>_GetWorkingArea

Anyone have idea how to cleanly solve this?

Just adding a couple of pixels is not cleanly to me.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...