Function Reference


_GUICtrlMenu_SetMenuDefaultItem

Sets the default menu item

#include <GuiMenu.au3>
_GUICtrlMenu_SetMenuDefaultItem ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu Menu handle
$iItem Identifier or position of the default menu item or -1 for no default item
$bByPos [optional] Menu identifier flag:
    True - $iItem is a 0-based item position
    False - $iItem is a menu item identifier

Return Value

Success: True.
Failure: False.

Related

_GUICtrlMenu_GetMenuDefaultItem

See Also

Search SetMenuDefaultItem 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