Jump to content

Select text and use it


Recommended Posts

Hi,

 

I have this text shown in text editor (note empty line after):

JRA-123 - Task Title

and some https://www.example.com/dynamic URL in clipboard and I want to combine them into this, that will replace original text in editor:

Fixes JRA-123 - Task Title

Differential Revision: https://www.example.com/dynamic

and I want to use "Snippet Trigger" for that with "fx" keyword so that I've type "fx" in any editor place and replacement happens.

 

I've faced couple of problems so far:

  1. sending "Command+A" shortcut to the text editor via "Output > Dispatch Key Combo" can't be done as workflow action (in the middle) - I've tried to select text and immediately use selection inside Alfred
  2. capturing selected text can only be done via "Triggers > Hotkey" and it can't be used as workflow action (in the middle) as well - I've tried to capture what should be selected above

 

Thanks.

Edited by aik099
Link to comment

GUI automation, like sending keyboard shortcuts, is error prone and should be done as a last resort. Ideally, your editor would support AppleScript and you could control it that way. Another safer way to approach it would be selecting the text yourself and using the Hotkey, but you’ve already excluded that.


Caveats out of the way, it can indeed be done but it won’t be pretty. You’ll need to connect a Snippet Trigger to a Dispatch Key Combo Output (⌘A) that connects to another Dispatch Key Combo Output (⌘C) that connects to a Copy to Clipboard Output. Because this will finicky and some actions can trample others, make sure to add a Delay Utility between each step (0.5 seconds might suffice).

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...