hello, im new to AppleScript, and I’d like to know how to make a script to dump a bunch of random words into whatever app happens to be open at the time using the System Events keystroke thing
You want to GUI type to front most application. Two ways, I like first when.
--Just to make sure you are somewhere that except type
tell application "TextEdit"
activate
make new document
end tell
-- Get the Frontmost then tell
tell application "System Events"
set {FrontMostProcess} to processes whose frontmost is true
tell process FrontMostProcess
keystroke "AppleScript is cool"
end tell
end tell
--Tell Directly
set MyVariable to " and there are different ways to do things."
tell application "System Events"
tell (processes whose frontmost is true)
say "I'm Typing"
keystroke MyVariable
delay 2 --wait for the GUI to do its thing before next step
keystroke " Now you expand from here..."
end tell
end tell
Have Fun