检索菜单项的禁用状态
#Include <GuiMenu.au3>
_GUICtrlMenu_GetItemDisabled($hMenu, $iItem[, $fByPos = True])
$hMenu | 菜单句柄 |
$iItem | 菜单项的标识符或位置,由 $fByPos 参数决定. |
$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 enabled
Writeln("Open is disabled: " & _GUICtrlMenu_GetItemDisabled($hFile, 1))
_GUICtrlMenu_SetItemDisabled($hFile, 1)
Writeln("Open is disabled: " & _GUICtrlMenu_GetItemDisabled($hFile, 1))
_GUICtrlMenu_SetItemEnabled($hFile, 1)
Writeln("Open is enabled : " & _GUICtrlMenu_GetItemEnabled($hFile, 1))
EndFunc ;==>_Main
; 写入一行文本到记事本
Func Writeln($sText)
ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CR)
EndFunc ;==>Writeln