Function Reference


_GUICtrlMenu_GetItemRect

Retrieves the bounding rectangle for the specified menu item

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemRect ( $hWnd, $hMenu, $iItem )

Parameters

$hWnd Handle to the window containing the menu
$hMenu Handle of the menu
$iItem 0-based position of the menu item

Return Value

Returns an array with the following format:
    [0] = X coordinate of the upper left corner of the rectangle
    [1] = Y coordinate of the upper left corner of the rectangle
    [2] = X coordinate of the lower right corner of the rectangle
    [3] = Y coordinate of the lower right corner of the rectangle

Related

_GUICtrlMenu_GetItemRectEx

Example

#include "Extras\HelpFileInternals.au3"

#include <GuiMenu.au3>

Global $g_hWnd

Example()

Func Example()
    Local $hMain, $aRect

    ; Open Notepad
    Run("notepad.exe")
    $g_hWnd = WinWaitActive("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($g_hWnd)

    ; Get File menu rectangle
    $aRect = _GUICtrlMenu_GetItemRect($g_hWnd, $hMain, 0)

    Writeln("File X1: " & $aRect[0])
    Writeln("File Y1: " & $aRect[1])
    Writeln("File X2: " & $aRect[2])
    Writeln("File Y2: " & $aRect[3])

    _NotepadForceClose($g_hWnd)
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText, $hWnd = $g_hWnd)
    ControlSend($hWnd, "", ControlGetFocus($hWnd), $sText & @CRLF)
EndFunc   ;==>Writeln