【问题标题】:AppleScript using end key and up arrowAppleScript 使用结束键和向上箭头
【发布时间】:2016-12-20 19:14:49
【问题描述】:

我正在尝试创建一个苹果脚本,该脚本将数据从名为 Panorama 的应用程序复制并粘贴到 Excel 2011 for Mac。我的一切工作几乎都按照我想要的方式工作,除了让 excel 移动到相邻列并移动到第一个记录位置(键盘快捷键是“结束”键和向上箭头。我不知道如何让 applescript 识别与向上箭头组合的结束键。如果有人能告诉我如何做到这一点或其他方式,将不胜感激。

到目前为止,这是我的代码:

重复2次

repeat 2 times

    tell application "Panorama" to activate
    tell application "System Events"
        tell process "Panorama"
            keystroke "c" using command down
            tell application "System Events" to keystroke (ASCII character 31)
        end tell
    end tell

    delay 0.8

    tell application "Microsoft Excel" to activate
    tell application "System Events"
        tell process "Microsoft Excel"
            keystroke "v" using command down
            tell application "System Events" to keystroke (ASCII character 31)
        end tell
    end tell

    delay 0.8

end repeat

tell application "Panorama" to activate
tell application "System Events"
    tell process "Panorama"
        tell application "System Events" to keystroke (ASCII character 29)
        tell application "System Events" to key code 115

    end tell
end tell

delay 0.8

tell application "Microsoft Excel" to activate
tell application "System Events"
    tell process "Microsoft Excel"
        tell application "System Events" to keystroke (ASCII character 29)
        tell application "System Events" to keystroke End using up arrow <----(This is the part not working.)
    end tell
end tell

delay 0.8

结束重复

【问题讨论】:

    标签: applescript osx-snow-leopard


    【解决方案1】:
    tell application "System Events" to key code 119 -- End key
    tell application "System Events" to key code 124 -- right arrow
    

    See this reference page of key codes

    【讨论】:

    • 我厌倦了你的建议,现在我收到一条错误消息:
    • 对不起,我过早地按了输入,错误说是预期的行尾,但找到了数字。知道这意味着什么吗?
    • 我想通了。我在“关键代码”中没有空格。我把它写成“keycode”。这行得通。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2010-09-21
    • 2011-01-02
    • 2010-09-28
    • 2021-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多