Typing with Applescript

蹲街弑〆低调 提交于 2019-12-25 03:59:14

问题


Is it possible to have my mac type for you with applescript? What I want is this: when compiled, this applescript will type a phrase, then press enter. Is there any code simulating the pressing of keys?


回答1:


The keystroke command will work for you.

tell application "System Events" to keystroke "A phrase" & return & "Another phrase"

If you want a specific application to do the typing, just do something along these lines:

tell application "System Events" to tell process "TextEdit" to keystroke "A phrase" & return & "Another phrase"



回答2:


Yes, look at keystroke and key down in System Events > Processes Suite, though you have to turn on Universal Access



来源:https://stackoverflow.com/questions/7661348/typing-with-applescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!