Reveal Emoji & Symbols Panel (Character Viewer)

Hi smart people!

Is there a way to use KM to access menu items in, for instance, the "Keyboard" menu, which doesn't have a standard name in the menu bar? I'm looking specifically for a way to select "Show Emoji & Symbols" in an application that has a built-in conflict with the standard hotkey for that function.

The "Select or Show a Menu Item" action seems to require an actual named title, doesn't it?

Thanks for whatever suggestions you can offer!

David

Have you tried to select the item in the Edit menu named "Emoji & Symbols"? Then that becomes the frontmost window. (I haven't tried this, but I think it should work in theory.)

1 Like

This may be of some help.

If nothing else works, try this

image

Hey David,

This is how you would go about opening Emoji & Symbols using AppleScript to drive the menu item.

Try running it from Apple's anemic Script Editor app, and see if this will work as is on your system.

set bailOutTime to 20

tell application "System Events"
   tell application process "SystemUIServer"
      tell menu bar 1
         tell (first menu bar item whose accessibility description is "text input")
            perform action "AXPress"
            tell menu 1
               tell menu item "Show Emoji & Symbols"
                  repeat until exists of it
                     set bailOutTime to bailOutTime - 1
                     delay 0.25
                     if bailOutTime ≤ 0 then error "Timeout Exceeded!"
                  end repeat
                  perform action "AXPress"
               end tell
            end tell
         end tell
      end tell
   end tell
end tell

It works for me on macOS Mojave, but it may require adjustments for other versions of macOS.

-Chris

1 Like

Great!

I have just tweaked your script so that it will show or hide the Emoji & Symbols panel, depending on whether or not it's already open.

Edit: @ccstone has asked me to mention the version of MacOS this modified script has been tested under. It's the same as for Chris's original script, that is, Mojave.

set bailOutTime to 20

tell application "System Events"
	tell application process "SystemUIServer"
		tell menu bar 1
			tell (first menu bar item whose accessibility description is "text input")
				perform action "AXPress"
				tell menu 1
					if menu item "Show Emoji & Symbols" exists then
						set symbols_menu to "Show Emoji & Symbols"
					else
						set symbols_menu to "Hide Emoji & Symbols"
					end if
					tell menu item symbols_menu
						repeat until exists of it
							set bailOutTime to bailOutTime - 1
							delay 0.25
							if bailOutTime ≤ 0 then error "Timeout Exceeded!"
						end repeat
						perform action "AXPress"
					end tell
				end tell
			end tell
		end tell
	end tell
end tell

1 Like

This looks really promising, y'all. Thanks so much! Cutting and pasting @kevinb's version into ScriptEditor I get this:

error "System Events got an error: Can’t get menu bar 1 of application process "SystemUIServer". Invalid index." number -1719 from menu bar 1 of application process "SystemUIServer"

I assume that's because my menu items are in a different order than @kevinb's, so I'll try digging in a little over the next few days to see if I can find the right tweaks.

Thanks tons, both @ccstone and @kevinb, for the huge head start!

David

1 Like

Is Script Editor enabled under "Accessibility" in System Preferences (or System Settings as I understand it is now called)?

What happens if you try running the script within a Keyboard Maestro macro?

Which version of MacOS are you running?

More likely OS version -- in Ventura these things usually come under the purview of the "Control Center" process, not "SystemUIServer".

Echoing @kevinb -- what OS are you running?

If "Show Emojis and Symbols" is available as a menu item in the app concerned then @ikenassi's suggestion is probably the best way to go.

Ha! I missed that entirely...

That's certainly the simplest way to go.


Download: Open Emoji & Symbols.kmmacros (1.6 KB)
Keyboard Maestro Export

Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 10.14.6
  • Keyboard Maestro v10.2

  • Make certain the macro is installed in a global macro group.
  • Read the macro notes above.
1 Like

Ha echoed! I hadn't noticed that "Emoji & Symbols" shows up in the Edit menu in addition to the Keyboard Input menu. That's a much easier menu to call! :rofl:

Thanks, y'all, for your patient help and thoughtful suggestions! Problem solved!

1 Like