I would like to open a new terminal window with "hello world" without the command being pressed, ie without pressing enter
I open the new window of the terminal but I can not write "Hello World".
How can it be done?
The code (in Script Editor):
do shell script "open -a Terminal"
The following example AppleScript code does as you asked:
tell application "Terminal"
if not (exists window 1) then reopen
activate
delay 0.5
tell application "System Events"
keystroke "k" using {command down}
keystroke "Hello World"
end tell
end tell
Note: Adjust the value of the delay
command as appropriate for the timing on your system.
You can also use the following, if you prefer:
do shell script "open -a Terminal"
delay 0.5
tell application "System Events"
keystroke "k" using {command down}
keystroke "Hello World"
end tell