Search code examples
macosapplescriptkeyboard-shortcutsalfred

Alfred: Workflow "Expected end of line" error in AppleScript


I have set up a workflow using Alfred. The workflow opens a bunch of applications. As a part of this workflow, I also want Stay to restore the window positions to the preset arrangement I have created.

For Stay, I use the "global" keyboard command Shift + + Å to restore the windows. This keyboard shortcut is set in the application's preferences.

I have created this NSAppleScript in Alfred:

on alfred_script(q)
delay 5
tell application "System Events"
    keystroke "Å" using shift down, command down
end tell
activate application "Evernote"
end alfred_script

However, I can't get it to work. I'm getting these errors according to the Alfred workflow debug:

[ERROR: alfred.workflow.action.applescript] {
    NSAppleScriptErrorBriefMessage = "Expected end of line but found \U201c,\U201d.";
    NSAppleScriptErrorMessage = "Expected end of line but found \U201c,\U201d.";
    NSAppleScriptErrorNumber = "-2741";
    NSAppleScriptErrorRange = "NSRange: {92, 1}";
}

enter image description here enter image description here


Solution

  • The keystroke / key code command using > 1 modifier keys needs curly brackets:

    keystroke "Å" using {shift down, command down}
    

    AppleScript Language Guide