Rawling Posted December 3, 2009 Posted December 3, 2009 I'm currently writing an automation script to test a Windows Forms app I've been working on, written in C#/.NET. Thus far my only interaction with context menus has been to send +{F10} to the control they belong to show them, then {DOWN x} to select the correct item and {ENTER} to click it. However, I now need to check whether certain items are disabled or not. I've searched and have only found references to Auto3Lib or the _GUICtrlMenu UDFs, which seem more concerned with creating menus than dealing with existing ones. Is there something blindingly obvious I've missed?
zfisherdrums Posted December 4, 2009 Posted December 4, 2009 This is reaching back a bit, so forgive me if the details are sketchy.When I had to automate context menus on WinForm apps - and I had to use AutoIT - then I had to utilize Microsoft Active Accessibility. There is a DLL available for download somewhere on the forum; search for "MSAA".I had to obtain a reference to the context menu's active accessibility interface. To do this, I had to get the window handle; all popup menus have a window class of #32768 if I recall correctly. Bear in mind that the context menu is not owned by the WinForm client or control, but rather belongs to the desktop.Once you get the window reference, you can get the Active Accessibility interface. Children nodes in the Accessibility Tree can expose propeties based on their type. Menu items have a (de)selected, (dis|en)abled property.I think the best way to start is to download these tools from Microsoft and observe the context menu.Sorry I can't give a working solution, but this should give you some direction.Zach... Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog...
Rawling Posted December 4, 2009 Author Posted December 4, 2009 Cheers for the help, you definitely got me pointed in the wrong direction. Didn't have any luck with #32768 or the desktop, but when I uncommented some of the debug code in ActiveAccessibility_Library.au3 (and changed it to output to console) and tried it with the class of the menu's parent window from MS's Inspect, I noticed one of the children listed in the console was DropDown. I can now check for Enabled/Disabled status, and I may well write my own functions to list the children of some of my menu items. Many thanks.
Rawling Posted December 4, 2009 Author Posted December 4, 2009 Cheers for the help, you definitely got me pointed in the wrong right direction.Didn't have any luck with #32768 or the desktop, but when I uncommented some of the debug code in ActiveAccessibility_Library.au3 (and changed it to output to console) and tried it with the class of the menu's parent window from MS's Inspect, I noticed one of the children listed in the console was DropDown. I can now check for Enabled/Disabled status, and I may well write my own functions to list the children of some of my menu items.Many thanks.Oops.
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