IvanMathy / Boop

A scriptable scratchpad for developers. In slow yet steady progress.
https://boop.okat.best
MIT License
3.82k stars 352 forks source link

Feature Request: Global Shortcut Key to open a Boop Window #281

Open bitwisecook opened 3 years ago

bitwisecook commented 3 years ago

Having a global shortcut key to launch Boop with the paste buffer is incredibly useful. I currently achieve it with Automator but it would be useful to build this into the tool itself. This would require System Preferences > Security & Privacy > Accessibility permissions.

I currently do this with Automator.

  1. Launch Automator
  2. Start a new action
  3. Set the "Workflow receives" to "no input" in "any application"
  4. Find and drag "Launch Application" from the left
  5. Set the Application to "Boop"
  6. Save the action as "Launch Boop"
  7. Open System Preferences > Keyboard > Shortcuts > Services
  8. Find General > Launch Boop in the list and tick it
  9. Double-click it to add a shortcut
  10. Set the shortcut (I used cmd-shift-B)

Optional, before step 6,

  1. Find and drag "Run AppleScript" as a second action
  2. Enter the script:
    on run {input, parameters}
    tell application "System Events" to keystroke "a" using command down
    tell application "System Events" to keystroke "v" using command down
    tell application "System Events" to keystroke "a" using command down
    tell application "System Events" to keystroke "b" using command down
    tell application "System Events" to keystroke "*"
    tell application "System Events" to keystroke "a" using command down
    end run

image

image

adamlazz commented 3 years ago

Something like this can also be done using Hammerspoon:

local cmd_shift = {"shift", "cmd"}
hs.hotkey.bind(cmd_shift, 'b', function() hs.application.launchOrFocus("Boop") end)
pearcenuk commented 2 years ago

I've also done similar with Alfred https://github.com/pearcenuk/Alfred-public/tree/main/BOOPy

srudolph-credera commented 2 years ago

If you have text selected, Boop installs a global shortcut, B, that will send that text to Boop and open it if it's not already open.

srudolph-credera commented 2 years ago

And if you still want a shortcut to open Boop even without selected text, it's fairly easy to do now with the Shortcuts app:

image
lynton-dev commented 2 months ago

If you have text selected, Boop installs a global shortcut, ⌃⌥⌘B, that will send that text to Boop and open it if it's not already open.

This is good to know. Could an option to change the global shortcut be added to settings? This would have the added benefit of making the existence of the feature more obvious.

srudolph-credera commented 2 months ago

It appears to be defined in https://github.com/IvanMathy/Boop/blob/main/Boop/Boop/Info.plist - I couldn't find a ton of documentation on it outside of https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/SysServices/Articles/properties.html, but there didn't seem to be an obvious way to make it dynamic. That said, you could theoretically change it directly in /Applications/Boop.app/Contents/Info.plist and clear your services cache.

srudolph-credera commented 2 months ago

Curiosity got the better of me - I did end up finding some evidence of being able to change it dynamically: https://stackoverflow.com/questions/18776369/set-custom-keyequivalent-in-services-menu.