Enabling
UI Scripting.
User Interface Scripting allows AppleScript to control the
same menu keyboard shortcuts, menu items and controls the
user can. So the following scriptlet will paste what's on
the clipboard into the current cursor position in TextEdit
(courtesy of Tom_X):
tell
app "System Events"
tell process "TextEdit"
keystroke "v" using command down
end tell
This makes AppleScripting a lot easier since you can figure
out keyboard shortcuts by checking an application's menu.
The problem is that UI scripting is off by default. To turn
it on, you need to go to your System Preferences, Click
Universal Access and then check "Enable access for
assistive devices". Not too hard, but still a pain for
anyone you give your apps or workflows too, since they need
to turn it on as well.
This little app
(created with Automator) will do everything in the process
for you, except check the box. For security reasons, it's
probably better that people check the box themselves. Feel
free to distribute this app with your workflows and apps.
You'll find more about UI Scripting on the related
Apple page.