5

how can I use applescript to type in a specified area on the screen? I've tried the 'keystroke' command, but it doesn't seem to work. also, how can I use applescript to display an image? thanks a lot if you answer. here's the code I have so far:

set theText to text returned of (display dialog "Put what you want to autotype here." default answer "" buttons {"OK", "cancel"} default button 1)
display dialog "select where you want me to type " & theText & " Your text will be typed in the area selected. you have 10 seconds to select once you click 'OK'" buttons {"OK"}
delay 10
say "typing"
--command for typing here
end
end
end
  • 3
    i think you need to learn to walk before you can run. Try a beginner's guide - computers.tutsplus.com/tutorials/… or macosxautomation.com/applescript/firsttutorial/index.html would be a fair start. Also, Ask Different is designed for one Question, one Answer. Multiple Questions need to be split. You also need to show what research you have done so far & what specific issue you are facing. Questions that are too broad will just be closed. – Tetsujin Jul 5 '15 at 17:36
  • sorry, but that's not helpful a bit. – gophereatingapickle Jul 5 '15 at 21:19
  • 2
    Which problem are you trying to solve in the end using the script (e.g. what is this "specified area": a window, a dialog box, something else)? Also your script seems to be syntactically incorrect, is it taken out of a bigger script? – nohillside Jul 6 '15 at 11:57
5

AppleScript from http://www.sythe.org/runescape-scripts/1590890-auto-typer-script-mac.html

tell application "System Events"
  set textToType to "text here"
  delay 3

  repeat
    delay 1
    keystroke textToType
    keystroke return
  end repeat
end tell

Replace within the quotes of "text here" to what ever you need. If you have multiple lines of text to auto type, then add more set textToType2 to "text here 2" and keystroke textToType2 keystroke return

Also with basic coding knowledge you can change a few parts to your choice. I've tried this script and works really well, however not as the best one for Windows only, rsclient.exe

0

You can also use key code to type individual keys or achieve most functions using your keyboard.


key code 8 using {command down, shift down} --> ⌘+shift+C

Here is the full list of key codes: https://eastmanreference.com/complete-list-of-applescript-key-codes

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .