CygnusX1 Posted March 9, 2017 Share Posted March 9, 2017 (edited) Hey, I'm trying to determine whether a menu item is enabled or not. _GUICtrlMenu_GetItemEnabled is returning inconsistent results. It returns True when a menu item is clearly grayed/disable. Actually, all of the menu functions are inconsistent _GUICtrlMenu_GetItemGrayed, _GUICtrlMenu_GetItemState, _GUICtrlMenu_GetItemDisabled, etc... My function looks like this, maybe it's me. Func FileExportMenuState() NewModel() $sSubMenu = _GUICtrlMenu_GetItemSubMenu($hMenu, 0) $sSubSubMenu = _GUICtrlMenu_GetItemSubMenu($sSubMenu, 15) $iCount = _GUICtrlMenu_GetItemCount($sSubSubMenu) $sActual = "" For $x = 0 To $iCount - 1 $sType = _GUICtrlMenu_GetItemType($sSubSubMenu, $x) If $sType <> 2048 Then $sActual = $sActual & _GUICtrlMenu_GetItemEnabled($sSubSubMenu, $x) $sText = _GUICtrlMenu_GetItemText($sSubSubMenu, $x) ;~ ConsoleWrite($sText & @CRLF) EndIf Next Sleep(1000) ;~ ConsoleWrite($sActual & @CRLF) Assert("FileExportMenuState() ", $sFileExportMenuStatus, $sActual) EndFunc ;==>FileExportMenuState _GUICtrlMenu_GetItemEnabled is returning True for all 4 of the menu items in the Export flyout in the attached image. Any help would be appreciated. Brad Edited March 10, 2017 by CygnusX1 Added image and more text Cygnus Link to comment Share on other sites More sharing options...
InnI Posted March 9, 2017 Share Posted March 9, 2017 Very often, the menu items change state when you call the menu. Try to get the status of the item when the menu is displayed. Link to comment Share on other sites More sharing options...
CygnusX1 Posted March 9, 2017 Author Share Posted March 9, 2017 That was actually what the problem! Thank you! At the beginning of my script I'm invoking all the menus to be displayed for a split second and now it is working great. Thanks again. Brad Cygnus Link to comment Share on other sites More sharing options...
CygnusX1 Posted March 10, 2017 Author Share Posted March 10, 2017 Ok, I thought it was solved but it isn't. I adjusted the script to open the menu while I'm getting the menu state. The video clearly shows a menu is grayed and the state of the menu is being returned as enabled. The opposite is also true, some active menus are being returned as not enabled. Any thoughts as to what is going on? Thank you, Brad menus.mp4 Cygnus Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now