将 Applescript [key code 125 using command down] 翻译成 appscript [英] Translate Applescrip [key code 125 using command down] to appscript

查看:54
本文介绍了将 Applescript [key code 125 using command down] 翻译成 appscript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将以下 Applescript 翻译成 appscript:

how to translate the following Applescript to appscript:

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

我想执行类似Command + A"的快捷方式,即选择所有文本.

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

推荐答案

查看作为 Appscript 一部分安装的应用程序 ASTranslate.它将 Applescript 转换为适用于 Python 或 Ruby 的 Appscript.请注意,它只会捕获 Apple 事件,因此不会翻译 Applescript 结构,如循环等.它非常容易使用.在一个窗格中通过您的 Applescript,点击 cmd-R,它将生成翻译的 Appscript + Python 代码.对于您的示例,它是

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)

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

虽然偶尔你会发现一些东西在一般情况下无法正常工作,但 ASTranslate 是使用 Appscript 的重要工具.

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

这篇关于将 Applescript [key code 125 using command down] 翻译成 appscript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆