Reputation: 781
Trying to run an JXA script (basically AppleScript) when a keystroke is pressed from any application. Got it working by using Automator and creating a service which is activated (and runs the script) when a certain keystroke is pressed.
The problem with this approach is that the script takes like half a second to actually run after the keystroke is pressed. Not a problem for most scripts, but I am trying to use a script in a game where responsiveness is important.
I am thinking I would need actually make the script 'listen' for keystrokes and then run the appropriate function when that keystroke is pressed, but not sure if that's even possible.
Does anyone have any ideas on this, whether making what I want work, or a different approach to running a script from a keystroke that can interact between programs.
Upvotes: 0
Views: 424
Reputation: 3792
The problem is with the Services/Automator wrapper. That is what takes a long time to load and then run, although it takes less time on subsequent calls. I would suggest installing a better launcher, like Quicksilver at http://qsapp.com. You can assign a global trigger to a script and it is lickety-split.
Upvotes: 2