How to code an AppleScript to do a mouse click on a menu bar item?
There's a scripting addition called "AppleScript Toolbox" (it's an osax). Get it at https://astoolbox.wordpress.com/

With that, you can simply write:

AST click at {10, 20}


That clicks into the menu bar, for instance, and opens the Apple menu.

If you want to preserve the original cursor position first, use this:

set origPos to AST mouse point location


And to restore it use:

AST set mouse point location origPos