2

I've been looking into tools like Karabiner, which are cool, but I would like more control. In general, I'd like to remap specific keys to run AppleScript or some other code.

Ideally it wouldn't send the keystroke though to the active application.

Is there any way to do this?

At the moment I'd like to remap the numpad keys to focusing specific applications, and if possible, specific windows in those applications. A general way to run code would be best, but anything that can accomplish this would be very much appreciated.

Brigand
  • 121
  • I believe Keyboard Maestro can do all of that. As with other similar programs that let you redefine keystrokes in order to trigger actions, it intercepts them before they get to the application originally intended to receive the keystrokes. You then decide what occurs from that point on. KM also has the ability to focus specific applications and, I believe, specific windows (referenced by index or title). – CJK Feb 27 '18 at 03:20
  • @CJK perfect! Please leave an answer so I can accept it. – Brigand Feb 27 '18 at 03:29
  • If you save your Applescripts in Automator as Services, you can call them by key command natively, no 3rd party apps required, though I've never checked whether they pass-through. I just avoid 'regular' key commands.. – Tetsujin Feb 27 '18 at 09:27
  • You can do this using Karabiner too... depending on your OS version. I made myself a launcher keyboard using a cheap bluetooth numpad and Karabiner (>>image<<). Though this was before Sierra using v.10.22.0. of Karabiner. That version of Karabiner supported detecting the active applicatio, triggering scripts and many other things. There was even an option to set alternative long press and double click (both of which I believe you can also do using Keyboard Maestro). – Joonas Feb 27 '18 at 11:52
  • I used to have a open files with photoshop button that opens selected files (in Finder or Path Finder) in photoshop and long pressing the same key just opened photoshop by itself. Karabiner had to be rebuilt to support sierra and so the Sierra version is lacking many of the features that were in the earlier version. The new version has been in the making for quite a while so I wonder how close it is right now. Just in case you are looking for alternative methods, there's the Elgato Stream Deck, which you can use for the same purpose. – Joonas Feb 27 '18 at 11:52
  • It's a little ...not great for this purpose in terms of setup, but the lcd keys and infinite folders are amazing. It doesn't support launching scripts right now, so I'm using Alfred to setup a shortcut that launches a script and then I just set a key in ESD to trigger the shortcut. Also at least my ESD has wobbly keys which isn't a big deal but it just feels like you are triggering the buttons twice when pressing due to the way they wobble. – Joonas Feb 27 '18 at 11:52
  • After using Keyboard Maestro for a bit, I'm very happy with it. Tons of commands, works with arbitrary inputs, e.g. it recognized "Das Keyboard Volume Up" (wheel input). I was able to configure that if I pressed a key, it'd focus a window, and then I press it again, and it goes to the previous window, and so much more. I haven't figured out how to simulate a keypress with a modifier. – Brigand Feb 28 '18 at 00:07
  • I think the Action you want is the basic Type a keystroke. Hold down modifier keys and then press the regular key. — KM is great. This is a bit stupid, but I think my favorite thing is navigating menu items. Because sometimes there are menu items you can't give a shortcut in the application. Simulating a click on that menu item in applescript is a pain in the ass, but in KM you just basically navigate the menu and choose the menu item you want KM to click. — Just in case you missed it, you can sync the macros by going to KM settings and pointing it to a sync folder (dropbox for example). – Joonas Feb 28 '18 at 08:07

0 Answers0