I know you can manipulate/select controls from the menu bar items for running apps (in upper left corner), but how can I do the same for the icons in the upper right corner?
All/Any Help appreciated Thanks!
there is no standard way to access these items. I recommend to use Automator to record a workflow that does this, then look at the generated Apple Script (by copying and pasting the recorded actions from Automator to a text editor.
Your example can be clicked via Apple Script like this:
tell application "System Events" to ¬
tell application process "TextInputMenuAgent" to ¬
tell menu bar item 1 of menu bar 2
click
click menu item "Show Keyboard Viewer" of menu 1
end tell
Being able to access menu bar items was recently added as a feature to Bartender and it is glorious. You can assign keyboard shortcuts to them from within the app, and even add modifier keys such as ⌘ ⌥ etc.
Bartender is an app that I recommend to anyone with a Mac. (If you have Setapp, Bartender is included; otherwise, it's $15 which is dirt cheap for all that it does. I would pay 3x that much.)