开发者

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

开发者 https://www.devze.com 2023-01-17 04:51 出处:网络
how to translate the fol开发者_开发知识库lowing Applescript to appscript: tell application \"System Events\"

how to translate the fol开发者_开发知识库lowing 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.


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.


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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消