On the wiki page for plug-ins lists 2 methods for retrieving Keyboard Maestro plug-in parameters from the environment variables, a 3rd way probably needs to be added.
- Use AppleScript
set myText to System Attribute "KMPARAM_My_Text"
- As noted this method is "not safe for international characters" (and emoji)
set myText to do shell script "echo $KMPARAM_My_Text"
- This method works with emoji and international characters but multi-line text (as from a TokenText form field) will be flattened into a single line
set myText to do shell script "printenv KMPARAM_My_Text"
- This works with emoji, international characters and multi-line text however printenv returns an error if KMPARAM_My_Text doesn't exist. You can catch this error with a try command. Final result:
try set myText to do shell script "printenv KMPARAM_My_Text" on error set myText to "" end try