Jump to content

Prevent "beep" for hotkey argument as "Selection in macOS" when no text is selected?


Recommended Posts

Hello! I created a workflow that, when the hotkey is pressed, will use the selected text as input, but if nothing is selected, fall back on using the current clipboard as the input. This is accomplished easily enough by passing the selected text to a script and checking if it's empty, and using `pbpaste` if it is. The problem is that with the hotkey node set to use the "Selection in macOS" as the argument, it makes a beeping noise if no text is selected. Is there a way to disable that beeping noise for such a node/workflow? Or, equivalently, is there a way to get the "Selection in macOS" reliably in the same way Alfred does from a script? (Preferably Shell or Python, but I'd make do with any.) Thank you for your time!

 

Alfred 4.6.3
macOS 12.2.1

Link to comment
  • 2 weeks later...
On 3/18/2022 at 12:27 AM, jackwayneright said:

The problem is that with the hotkey node set to use the "Selection in macOS" as the argument, it makes a beeping noise if no text is selected. Is there a way to disable that beeping noise for such a node/workflow? Or, equivalently, is there a way to get the "Selection in macOS" reliably in the same way Alfred does from a script?

 

The sound is coming from macOS, not Alfred. If you press your Hotkey when nothing is selected, you’ll both hear the beep and see the Edit menu of the app you’re in flash. If you press ⌘C in the same situation, you’ll get exactly the same thing. Copying is part of how the feature works.


You may still be able to get around it and find some API to get the text selection of apps, but I suspect it will end up being a finickier solution that might not work on non-native apps. Can’t say for sure, as I haven’t researched it.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...