BigDaddyO Posted December 5, 2018 Posted December 5, 2018 I'm using WinMenuSelectItem() successfully in the application I'm automating but i'm looking for another feature. I use WinMenuSelectItem to Process a record. I then need to use WinMenuSelectItem to Save the record, but I shouldn't save before the Process step above finishes (Save option is always enabled). Sadly, the only way to know if Processing actually finished is when another menu item gets enabled (but I don't want to select that other menu item, just wait until it's enabled) The AU3Info tool doesn't show me anything for the menu bar items so I can't use ControlCommand IsEnabled. Anybody have other ideas? Quick example using SciTE menu bar as they act the same, AU3Info can't see those menu items either. ;Undo in SciTE, then wait until Redo is enabled but dont click it. If WinMenuSelectItem("[CLASS:SciTEWindow]", "", "&Edit", "&Undo") Then ConsoleWrite("Undo clicked" & @CRLF) ;How to I know if "&Edit", "&Redo" is enabled? Else ConsoleWrite("Can't find Undo" & @CRLF) EndIf ;Erase this line then run/F5 to get back Thanks, Mike
BigDaddyO Posted December 5, 2018 Author Posted December 5, 2018 I figured it out by using the _GUICtrlMenu_ items. I always forget I can use those _GUICtrl functions on a lot of other apps. Anywho, here is the working code for the SciTE example I posted above. ;Undo in SciTE, then wait until Redo is enabled but dont click it. #include <GuiMenu.au3> $hWnd = WinGetHandle("[CLASS:SciTEWindow]", "") $hMnu = _GUICtrlMenu_GetMenu($hWnd) ConsoleWrite("Menu Handle = " & $hMnu & @CRLF) $iTopLvl = _GUICtrlMenu_FindItem($hMnu, "Edit") ConsoleWrite("Edit Item# = " & $iTopLvl & @CRLF) $hSubMnu = _GUICtrlMenu_GetItemSubMenu($hMnu, $iTopLvl) ConsoleWrite("Edit Menu Handle = " & $hSubMnu & @CRLF) ;Used to identify the item, needed the Ctrl+Y added to the _FindItem() ;~ For $i = 0 to 10 ;~ $sLabel = _GUICtrlMenu_GetItemText($hSubMnu, $i) ;~ ConsoleWrite("Edit Menu " & $i & " = " & $sLabel & @CRLF) ;~ Next $iRedo = _GUICtrlMenu_FindItem($hSubMnu, "Redo Ctrl+Y") ConsoleWrite("Redo Ctrl+Y Item# = " & $iRedo & @CRLF) ;Wait until the Redo item is enabled Do sleep(500) Until _GUICtrlMenu_GetItemEnabled($hSubMnu, $iRedo) ConsoleWrite("Finished! Redo is now enabled" & @CRLF) ;Run the script without modifying anything, else Redo will be enabled. ;Erase this line then then click Undo button at top. Script should End.
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