How do I execute commands such as typing out text, onto an unfocused application in the background?
For example, I want to have it type out text in a messaging application while I'm on my browser.
tell application "System Events"
activate
delay 4
repeat y times
keystroke x
delay z
keystroke return
end repeat
This is a section of the code I'm using, with x, y and z being message typed, times repeated and delay in between respectively. It works well when the window I want it to type in is in front, but how would I change it to allow me to designate the typing to a certain application?
Thanks in advance for any help.