How to initiate a specific keystroke using automator? I have the following code :

on run {input, parameters}
    if application "KeyboardViewer" is running then
        quit application "KeyboardViewer"
    else
        activate application "KeyboardViewer"

    end if
    return input
end run



I want to press ALT + TAB automatically after I activate application so that I can start typing right away .. 
Reason to do this is because the keyboard becomes the foreground running application and the webpage or typing area the background.
You can use the keystroke scripting command available through the System Events application.

Add the following block to your script below (and at the same indent level as) the activate:

tell application "System Events"
    keystroke tab using {command down}
end tell


This will simulate cmd+tab and have the effect of switching applications.

To simulate the "ALT" modifier key, use option in place of command in the above.