Keystroke delay
  • Recently, my keystroke invocations are waiting until the modifier keys are released; e.g. I type control-D and the script doesn't start until I release the control key even if I hold it for 10 seconds. During this time, the fastscripts icon turns blue.

    I noticed your release note: "Prevent conflicts with synthesized "key code" command and script keyboard shortcut". So is this a new behavior to avoid such conflicts? If so, is there any way to turn it off, as I use the commands to either delete (Control-D) or file (Control-F) my mail, just holding down the control key and typing D or F on each piece? I do generate a code in the script (down arrow to leave my cursor where it was after filing/deleting), but the control modifier doesn't affect it.

    Related but independent question, does this mean that people don't need to add the delay 0.5 anymore?
  • Hi - it's definitely a side-effect of that change. I decided the vast majority of the time it would be preferable to wait until all the keys are lifted, to avoid unwanted side effects. Yes, it does mean the whole workaround with delays to avoid those conflicts is totally unnecessary.

    I realize it's a drag to have to get in the habit of lifting the keystroke completely. Maybe it does need a workaround for folks where the remaining modifier keystroke isn't causing any conflict.
  • Well, I've given it a few weeks, and it still is very annoying. Any possibility of a workaround (terminal pref setting, comment in script, etc)?
  • Hi Mackworth, sorry, I don't know of any workaround to prevent the behavior in the current release. As long as you are still holding the keys, it will hold up and refuse to continue the keystroke command in your script until the keys are lifted.

    I noticed a little nuance of your original report that I don't think is true: you say that until you release the key the script doesn't start. What should actually be happening is the script will run, and run to completion, until or unless it encounters a synthesized keystroke command, then it will pause until you release the keys.

    At this point I think the only sure workaround would be to downgrade to FastScripts 2.6, which you can download here:

    http://www.red-sweater.com/fastscripts/FastScripts2.6.zip

    Daniel
  • I did just think of one other workaround. If you are willing to save your script as a "Script Application" or as a shell script that invokes osascript to run the script, then you would not experience the effect of FastScripts trying to prevent a keystroke conflict with the synthesized keys.
  • Well, I rewrote the script (which uses a down-arrow keystroke to move to the next message when deleting or archiving an email, and changed it to ask Mail for visualMessages and move down one), but it made it much slower. I tried the Script Application route, but then it asks permission to run every time, the icon appears in the dock, and the script doesn't know it was called from Mail (which is one of my checks). I guess I'll go back to 2.6 for now. Thanks for the help, though!
  • I had an idea that I think will solve the problem for you. If you "outsource" the running of just the system events command to do the down arrow, then it will not trigger FastScripts's conflict-prevention delay:

    set myScript to \"osascript -e 'tell app \\"System Events\\" to keystroke (ascii character 31)'\"
    do shell script myScript


    This will spin off a separate shell script process to just do the system event synthesis. Works instantly on my Mac and doesn't delay even with the command key held down.
  • Thanks; that works really well. (I was reminded of the problem when I got the 2.6.4 upgrade notice, so came back to see if there was a suggestion).
  • Sigh. Lion seems to have broken this. now the osascript call returns error -10004, and the down-arrow keycode 125 does nothing at all. Any thoughts?
  • In my tests the down-arrow keycode still works fine in Lion, but I'm using keycode 31, as cited above. Was that a typo when you said keycode 125?
Start a New Discussion

Howdy, Stranger!

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