You need to capture the sub menu control, the main menu and sub menu are two controls.
Just use the QA Wizard to click the main menu and then click the sub menu during recording, then you can find the sub menu control. after that you can get the itemCount.
if you are recording against a web app then
if it is window then
just change the Browser to window and then it will do, just as you wrote in your original code
this is the general idea and easy one
If you want to capture a sub menu automatically based on a know main menu during playback.
I can offer two methods for that, but you need to know the strcuture of your target, like is the content of the sub menu dynamic or not? changeable according to database data? More details are reuqired. but ifjust a simply one, I think the first general method would fit.