Sets the state of a menu item
#include <GuiMenu.au3>
_GUICtrlMenu_SetItemState ( $hMenu, $iItem, $iState [, $bState = True [, $bByPos = True]] )
$hMenu | Menu handle |
$iItem | Identifier or position of the menu item |
$iState | Menu item state: $MFS_CHECKED - Item is checked $MFS_DEFAULT - Item is the default item $MFS_DISABLED - Item is disabled $MFS_GRAYED - Item is disabled $MFS_HILITE - Item is highlighted |
$bState | [optional] Item state to set: True - State is enabled False - State is disabled |
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier |
Success: | True. |
Failure: | False. |
_GUICtrlMenu_GetItemState, _GUICtrlMenu_GetItemStateEx
#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 Open item state
_GUICtrlMenu_SetItemState($hFile, 1, $MFS_CHECKED)
Writeln("Open item state: " & _GUICtrlMenu_GetItemStateEx($hFile, 1))
_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