pilotmoon / PopClip-Extensions

Source code for extensions in the official PopClip Extensions directory.
https://www.popclip.app/extensions/
MIT License
1.92k stars 442 forks source link

Question: Is there a way to select text and then trigger a shortcut #1200

Closed stevenlis closed 2 years ago

stevenlis commented 2 years ago

I'm trying to find an extension to trigger a shortcut after some texts are selected.

This could be useful when I need to select two lines of code and then run them in vscode (the run command is triggered by a shortcut)

https://user-images.githubusercontent.com/33796896/190938605-9720474f-750a-4e6e-ac7b-2821031b420e.mp4

pilotmoon commented 2 years ago

There sure is, here is some more info on how to do it: https://forum.popclip.app/t/how-to-make-a-key-press-extension-in-popclip-textexpander-example/328/19

stevenlis commented 2 years ago

@invariant Am I missing something here? I get an invalid key combo error and tried the following two snippets.

# popclip
name: run code
key combo: return shift
# popclip
name: run code
key combo: shift
pilotmoon commented 2 years ago

The modifiers have to be listed first so you need:

# popclip
name: run code
key combo: shift return

Also a modifier on its own (just shift) is invalid.

stevenlis commented 2 years ago

@invariant Thanks you. That works! Btw, is there a way to set a whitelist for this extension so that I could customize different shortcuts for different apps? I only found a global blacklist in the settings. CS-X8adMv5A

pilotmoon commented 2 years ago

Yes you can use the required apps field in the extension configuration. Details are in the extensions documentation in this repository readme

stevenlis commented 2 years ago

@invariant thank you!