Simple examples of simulating user actions with AppleScript.
-- Simple example of simulating user actions with AppleScript.
tell application "Terminal" to activate
tell application "System Events"
tell process "Terminal"
click menu item "New Window" of menu "Shell" of menu bar 1
tell application "Terminal" to close the front window
end tell
end tell
-- This example shows how to simulate pressing of the Command+Option+Shift+N hotkey
tell application "System Events"
tell application "iTunes" to activate
key code 45 using {command down, option down, shift down}
end tell