It should theoretically be possible to check this with getMenuCommandState.
However, this method found by kbsanders seems more reliable. I actually tried it.