Function Reference


_GUICtrlMenu_GetMenuDefaultItem

Retrieves the default menu item on the specified menu

#include <GuiMenu.au3>
_GUICtrlMenu_GetMenuDefaultItem ( $hMenu [, $bByPos = True [, $iFlags = 0]] )

Parameters

$hMenu Handle of the menu
$bByPos [optional] Determines whether to retrive the menu items's identifer of it's position:
    True - Return menu item position
    False - Return menu item identifier
$iFlags [optional] Specifies how the function searches for menu items:
    0 - No special search parameters
    1 - Specifies that the function will return a default item even if it is disabled
    2 - Specifies that if the default item is one that opens a submenu the function is to search recursively in the corresponding submenu.

Return Value

Success: the identifier or position of the menu item.
Failure: -1.

Related

_GUICtrlMenu_SetMenuDefaultItem

See Also

Search GetMenuDefaultItem in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
        Local $hWnd, $hMain, $hFile

        ; Open Notepad
        Run("notepad.exe")
        WinWaitActive("[CLASS:Notepad]")
        $hWnd = WinGetHandle("[CLASS:Notepad]")
        $hMain = _GUICtrlMenu_GetMenu($hWnd)
        $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

        ; Get/Set File menu default item
        Writeln("File menu default item: " & _GUICtrlMenu_GetMenuDefaultItem($hFile))
        _GUICtrlMenu_SetMenuDefaultItem($hFile, 1)
        Writeln("File menu default item: " & _GUICtrlMenu_GetMenuDefaultItem($hFile))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
        ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln