KM7 :Find the charactercode of a selected character

Trying to use a macro to add or remove a * - asterisk character from a wikitext item list

In wikitext, item lists are formatted as

* Item 1
** Item 1.1
* Item 2

Pseudocode am planning to use to remove '*'

# Go to the beginning of line
# Use SHIFT + RIGHT ARROW to select the first character
# If the character is  `*`
#    remove the character
# else
#    exit


  • How to use KM 7 to find if the selected character is an asterisk ?
  • Are there any steps that will help check if the selected character is in a list of characters
    • Is it possible to pass the selected character/s to a python script and use the tuple returned from that script in a KM Script ?

Generally the only way to reach the selection in Keyboard Maestro is to Copy and then read the clipboard. The exception being if the app is very AppleScriptable.

However there is an alternative that will work in quite a few apps, and that is to use the Find Pasteboard together with the FindPasteboard token.


  • Type a Keystroke: Command-E
  • If text % FindPasteboard% is *

Something like that. It wont work in every case, and you may have to watch the timing for how fast the pasteboard changes after the Command-E, but it is a way you can avoid the system clipboard.


Thank you. It works great.