Retrieves the default menu item on the specified menu
#include <GuiMenu.au3>
_GUICtrlMenu_GetMenuDefaultItem ( $hMenu [, $bByPos = True [, $iFlags = 0]] )
$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. |
Success: | the identifier or position of the menu item. |
Failure: | -1. |
_GUICtrlMenu_SetMenuDefaultItem
Search GetMenuDefaultItem in MSDN Library.
#include "Extras\HelpFileInternals.au3"
#include <GuiMenu.au3>
Global $g_hWnd
Example()
Func Example()
Local $hMain, $hFile
; Open Notepad
Run("notepad.exe")
$g_hWnd = WinWaitActive("[CLASS:Notepad]")
$hMain = _GUICtrlMenu_GetMenu($g_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))
_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