设置菜单项的灰色状态
#Include <GuiMenu.au3>
_GUICtrlMenu_SetItemGrayed($hMenu, $iItem[, $fState = True[, $fByPos = True]])
$hMenu | 菜单句柄 |
$iItem | 菜单项的标识符或位置,由 $fByPos 参数决定. |
$fState | [可选参数] 菜单项的状态: True - 启用状态 False - 禁用状态 |
$fByPos | [可选参数] 菜单识别标志: True - $iItem 为项目的 0 基位置 False - $iItem 为菜单项的标识符 |
成功: | 返回 True |
失败: | 返回 False |
#include <GuiMenu.au3>
_Main()
Func _Main()
Local $hWnd, $hMain, $hFile
; 打开记事本
Run("notepad.exe")
WinWaitActive("[CLASS:Notepad]")
$hWnd = WinGetHandle("[CLASS:Notepad]")
$hMain = _GUICtrlMenu_GetMenu($hWnd)
$hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)
; Get/Set Open grayed
Writeln("Open is grayed: " & _GUICtrlMenu_GetItemGrayed($hFile, 1))
_GUICtrlMenu_SetItemGrayed($hFile, 1)
Writeln("Open is grayed: " & _GUICtrlMenu_GetItemGrayed($hFile, 1))
EndFunc ;==>_Main
; 写入一行文本到记事本
Func Writeln($sText)
ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CR)
EndFunc ;==>Writeln