Applescript按键在BBEdit中不起作用

Applescript按键在BBEdit中不起作用,applescript,bbedit,Applescript,Bbedit,出错 tell application "BBEdit" activate tell window 1 repeat 100 times repeat 5 times key code 124 end repeat --select insertion point after character 5 keystroke return

出错

tell application "BBEdit"
    activate
    tell window 1
        repeat 100 times
            repeat 5 times
                key code 124
            end repeat
            --select insertion point after character 5
            keystroke return
            --keystroke key code 36
        end repeat
    end tell
end tell
我想做的就是模拟将光标移动5个空格,然后多次按回车键

看起来很简单

error "BBEdit got an error: Can’t get keystroke \"
\" of window 1." number -1728 from keystroke "
" of window 1
delay 0.2
tell application "BBEdit"
    activate
    tell window 1
        repeat 100 times
            repeat 5 times
                tell application "System Events"
                    key code 124
                end tell
            end repeat
            tell application "System Events"
                keystroke return
            end tell
        end repeat
    end tell
end tell