Don't do it! This is a really bad style of programming which will give you hard time a bit later. If you already came to the situation you need it, change your design; what you have now is wrong and will lead you nowhere.
Instead, have a separate function which is called from the handler of a menu item click and elsewhere.
If by some reason you still need to simulate a click or a keyboard input, use Windows API
SendInput
. It is low-level and highly universal, works exactly if you did the input using hardware. See
http://msdn.microsoft.com/en-us/library/ms646310(v=vs.85).aspx[
^].
—SA