system events keystroke modifier gets "stuck"
  • i've got a script to select the current line in coda, and it works fine if i run it from script editor but when i run it from fastscripts menu it's acting like "command down" is still in effect for the second keystroke... iow in script editor the following selects the current line, but in fs it selects to the end of the document. is there a way to "clear" the keystroke modifier between script steps? note that i've tried this script in textwrangler too, with the same effect.

    tell application "Coda"
    tell application "System Events" to keystroke (ASCII character 28) using command down
    tell application "System Events" to keystroke (ASCII character 31) using shift down
    end tell
  • ok, looks like this is only happening when i still have the command key held down from invoking the script using a keyboard shortcut. i wonder if there's a way to tell the script to ignore that?
  • Unfortunately I don't think there is a way. The classic workaround to this type of problem is to put a delay in your script to give you time to let go of the command key. E.g. "delay 0.5" ...

    It slows things down a bit, but it turns out that is necessary to keep it from getting confused.

    One of the downsides to FastScripts being ... fast ;)

  • ok, thanks... that workaround would sort of work, but ideally i'd be able to do something like cmd-L-X (cmd-l to select the line and cmd-x to cut it). better i guess would be to go ctrl-L for the script, so that at least i don't accidentally do the wrong thing (i.e. cut from cursor to end of document).
  • Yeah, using a different shortcut is another choice, but sometimes the OTHER modifier can also get in the way. I neglected to mention it, but another choice is you can set keyboard shortcuts in FastScripts that don't require a modifier at all. E.g. a function key could be a good choice here (though it's obviously more out of the way than the editing-related keys you're trying to use).

Start a New Discussion

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!