【问题标题】:Keystroke Fn (function) key in ApplescriptApplescript 中的按键 Fn(功能)键
【发布时间】:2023-09-20 05:06:01
【问题描述】:

有什么方法可以在苹果脚本中按 Fn 键?理想情况下,我希望能够“按”两次以启动语音输入。

提前致谢!

【问题讨论】:

    标签: applescript voice-recognition keystroke keystrokes


    【解决方案1】:
    delay 0.5 -- time to release modifier keys if the script is run with a keyboard shortcut
    tell application "System Events"
        key code 63 -- fn
        key code 63
    end tell
    

    有关密钥代码,请参见 Events.h 或 my website

    【讨论】:

    • 完美运行!您是否偶然知道如何通过苹果脚本打开文件夹?我认为我的问题是文件路径中的空格... /Users/username/Library/Speech/Speakable Items
    【解决方案2】:

    在 applescript 中,您的文件路径必须是 macpath 而不是 unixpath,即用冒号(而不是正斜杠)分隔目录,例如,

    tell application "Finder"
        open folder "Macintosh HD:Users:username:Library:Speech:Speakable Items"
    end tell
    

    【讨论】: