Translate Applescrip [key code 125 using command down] to appscript

孤者浪人 提交于 2019-12-12 01:35:10

问题


how to translate the following Applescript to appscript:

tell application "System Events"
    key code 0 using command down
end tell

I want to perform "Command + A"-like short cut, i.e., select all texts.


回答1:


Look at the application ASTranslate which was installed as part of Appscript. It translates Applescript to Appscript for Python or Ruby. Be aware it just traps Apple Events and thus won't translate Applescript structures like loops or the like. It's very easy to use. Just past your Applescript in one pane, hit cmd-R, and it'll generate the translated Appscript + Python code. For your example it is

app(u'System Events').key_code(0, using=k.command_down)

While occasionally you'll find something that won't work quite right in general ASTranslate is an essential tool for using Appscript.




回答2:


Bellow is the usage of keystroke of Applescript via Python, which is hard to search:

http://www.agapow.net/programming/python/applescript-via-python



来源:https://stackoverflow.com/questions/3745040/translate-applescrip-key-code-125-using-command-down-to-appscript

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