【问题标题】:Translate Applescrip [key code 125 using command down] to appscript将 Applescript [key code 125 using command down] 翻译成 app 脚本
【发布时间】:2010-09-19 08:37:03
【问题描述】:

如何将以下 Applescript 翻译成 appscript:

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

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

【问题讨论】:

    标签: applescript keycode sourceforge-appscript


    【解决方案1】:

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

    app(u'系统事件').key_code(0, using=k.command_down)

    虽然您偶尔会发现一些通常无法正常工作的东西,但 ASTranslate 是使用 Appscript 的必备工具。

    【讨论】:

    • 非常好,非常好用,节省了我很多在开发中寻找解决方案的时间。谢谢。
    【解决方案2】:

    下面是Applescript通过Python的keystroke的用法,很难搜索:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-25
      • 1970-01-01
      • 2013-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多