Applescript 按键向下命令不';我不能用普通钥匙工作

Applescript 按键向下命令不';我不能用普通钥匙工作,applescript,key,Applescript,Key,假设我想按“c”键5秒钟,然后释放它。这就是我想做的: tell application "System Events" key down "c" delay 5 key up "c" end tell 但它就是不起作用。不管字母是什么,它总是按“a”。我甚至试过使用键代码8(相当于c),但它也不起作用。您应该使用命令击键。所以代码看起来像这样: tell application "System Events" set fiveSecondsFromNow to

假设我想按“c”键5秒钟,然后释放它。这就是我想做的:

tell application "System Events"
    key down "c"
    delay 5
    key up "c"
end tell

但它就是不起作用。不管字母是什么,它总是按“a”。我甚至试过使用键代码8(相当于c),但它也不起作用。

您应该使用命令
击键
。所以代码看起来像这样:

tell application "System Events"
    set fiveSecondsFromNow to (time of (current date)) + 5
    repeat until (time of (current date)) is fiveSecondsFromNow
        keystroke "c"
    end repeat
end tell

您应该使用命令
击键
。所以代码看起来像这样:

tell application "System Events"
    set fiveSecondsFromNow to (time of (current date)) + 5
    repeat until (time of (current date)) is fiveSecondsFromNow
        keystroke "c"
    end repeat
end tell

这是正常的行为<代码>向上/向下键仅适用于修改器键⌃⇧⌥⌘.用普通钥匙怎么做?我需要按住一个键,不能用香草AppleScript。也许使用AppleScripto是正常的行为<代码>向上/向下键仅适用于修改器键⌃⇧⌥⌘.用普通钥匙怎么做?我需要按住一个键,不能用香草AppleScript。也许用AppleScriptObjC