espanso / espanso

Cross-platform Text Expander written in Rust
https://espanso.org
GNU General Public License v3.0
10.06k stars 277 forks source link

Output control keys (tab, ctrl, cmd, shift, esc) #286

Closed PerpetualCreativity closed 2 months ago

PerpetualCreativity commented 4 years ago

It would be cool if we could do something like: replace: "<cmd>f</cmd" for cmd+f (or similar). This would be especially useful on Windows, where I use win+r "application name" a lot.

federico-terzi commented 4 years ago

Hey @PerpetualCreativity,

Thank you for the feedback! I'm not really sure how you would trigger that though. I mean, all these matches are activated when you type a given trigger, but where would you type the trigger?

If possible give me a bit more details about your use case.

Cheers :)

jorgechurriana commented 4 years ago

The same that you can write /n in the replace key, why not using \t for tab?

federico-terzi commented 4 years ago

@jorgechurriana it depends on the OS, but in some applications, this is already supported

jorgechurriana commented 4 years ago

@jorgechurriana it depends on the OS, but in some applications, this is already supported

Windows?

federico-terzi commented 4 years ago

Windows?

On Windows, it only works on some applications unfortunately

tnorthcutt commented 3 years ago

Is there anything that would help move this forward? I've never written any Rust so I wouldn't even know where to start in adding this functionality, but at this point the inability to send a tab character is the thing keeping me from fully adopting espanso. I do lots of frontend development work and being able to fill out a long form with a few keystrokes is a huge time saver as I'm often testing a form many times while working on it. I'd love to use espanso for this and finally remove aText completely.

federico-terzi commented 3 years ago

@tnorthcutt Thank you for the help! At the moment, there is not much you can do as the core is being rewritten and things will likely break a lot :) That said, the new core takes into account this requirement, so I hope to ship this feature within the next few releases :)

tnorthcutt commented 3 years ago

I thought of something that might be informative related to this feature request: a key part of my workflow with the tool I currently use for complex text expansions (aText) to fill out forms is the ability to add in delays both before and after a key is output. Sometimes web forms are a bit weird and I've found many cases where adding a delay (of 0.1 or 0.2 seconds) before a tab key solves the problem entirely.

I don't know if you'd planned on adding that ability to espanso, but I wanted to mention it now in case it's easier to add in now rather than later.

Cheers!

federico-terzi commented 3 years ago

Hey @tnorthcutt, thank you for the feedback! I'll make sure to add a delay option as well :)

xeor commented 2 years ago

Another usecase for a TAB is with logseq. I am using espanso to get advanced templates-support in it, but it fails because I can't indent and create sub-blocks (which is a huge deal with logseq)..

federico-terzi commented 2 years ago

Hey @xeor,

Thank you for the feedback! In the meanwhile, you might have some luck with the force_clipboard option, see: https://github.com/federico-terzi/espanso/issues/962#issuecomment-1021531595

Cheers :)

alexn-s commented 2 years ago

love espanso and i appreciate your work 💖.

are there any updates for this feature?

rodrcastro commented 2 years ago

One other use case to add to this is in my workflow. I work in support, and whenever I finish a reply to a customer, I send my signature set in Espanso. After that, I can hit tab twice to change to a field where I can assign myself to that response by writing "me". So, it would be nice to have in my signature something like:

Have a wonderful day, Rodrigo Espanso hits tab twice for me me

I have to do this for every ticket I reply, which is not a huge deal, but it's something that could save me some time in every reply. I used it a lot when I used TextExpander, but I like the flexibility of Espanso better.

Fischmuetze commented 2 years ago

In the meanwhile: Is there a solution to send keystrokes (e.g. TAB) via espanso to the system? Came froma aText on macOS and was using that for filling automatically web forms. So in aText it is nor problem to define TAB-Key-jumps to jump to the next form field. How can I solve this with espanso (no \t will not work here). Otherwise I have to quit with this lovely espanso soon as I started with it.

extremenelson commented 2 years ago

Another logseq user here. The TAB key is critical for creating templates using espanso. Any idea when this might be implemented?

srmippili commented 2 years ago

Any idea when TAB and Enter etc.. keys feature, would be available. Eagerly waiting for this feature

nwildner commented 1 year ago

+1 on this.

It would be very useful for situations where you need to jump to the end of the text form before inputting more text. Example:

  - trigger: ":scope"
    replace: |
             Having said the above, please note that since this is a system administration task[], 
             it is not within the scope of support. Please also note that support will be provided 
             on a best effort basis as per our documentation[]
             META+DOWN

             [] - https://mycompany.com/kb/00000001
             [] - https://mycompany.com/kb/00000002

  - trigger: ":upgrade"
    replace: |
             The upgrade process of this software can be found here[]
             META+DOWN

             [] - https://mycompany.com/kb/00000003

 - trigger: ":ref"
   replace: |
             References
             ====================================

I'm using META+DOWN as it is a Mac-ish input to jump to the end of a text form, but it could be CTRL+END on other OSs.

In both cases, to provide Support scope snippet(:scope) or software upgrade snippet(:upgrade), and also being able to jump to the end of document before the "links part" of those snippets is something that would greatly increase productivity from a Customer Support Engineer perspective.

Raul-M-P commented 1 year ago

Hi @federico-terzi, Maybe you could get some ideas for implementing from here https://sikulix-2014.readthedocs.io/en/latest/keys.html

Milor123 commented 1 year ago

How can i replace a \n by a hold LEFT-SHIFT + ENTER, using this project?

Fischmuetze commented 1 year ago

In the meanwhile: Is there a solution to send keystrokes (e.g. TAB) via espanso to the system? Came froma aText on macOS and was using that for filling automatically web forms. So in aText it is nor problem to define TAB-Key-jumps to jump to the next form field. How can I solve this with espanso (no \t will not work here). Otherwise I have to quit with this lovely espanso soon as I started with it.

Obviously the same condition as 10 months before. Jumping through the forms is essential for me as it is for some other users. Unfortunately Espanso is the only text expander tool I know that is not able to send keyboard input. A great pity.

herrmayr commented 1 year ago

Are there any updates on this feature request? One of my typical use cases, which unfortunately keeps me from fully embracing espanso instead of TextExpander, is sending emails, where I can enter an address, then press TAB TAB to go to the subject line, TAB to go to body, and then paste text ...

SergioInToronto commented 10 months ago

+1 on this thread. I'd be happy to help if that's possible.

AutoKey wasn't perfect but using a script to inject characters let me add delays, and having special characters like <left> let me put the cursor in between text I just injected (for example <a></a>). It's hard living without these features. I want espanso to be better than aText and AutoKey - I think it can be!

I'd like to add these features. Can you point me to the code where I should get started?

Kaushik-Rajarathinam commented 10 months ago

Is this feature going to be implemented. I would love an auto trigger sequence.

smeech commented 9 months ago

Output of tabs (\t) like newline \n is now possible and documented. Ctrl-keys which have an ASCII code can be used as inputs and outputs.

AndresMFIT commented 7 months ago

Output of tabs (\t) like newline \n is now possible and documented. Ctrl-keys which have an ASCII code can be used as inputs and outputs.

Hi, is there any planned implementation for Shift-keys?

smeech commented 7 months ago

Hi, is there any planned implementation for Shift-keys?

Unless I misunderstand your question, most <shift+keys> can be used already for triggers and replaces because they have characters associated with them.

For output of \ and \ keys, one has to resort to use of xdotool or similar utilities, I'm afraid.

assholehoff commented 6 months ago

Output of tabs (\t) like newline \n is now possible and documented. Ctrl-keys which have an ASCII code can be used as inputs and outputs.

Hi! Unfortunately this does not work for me.

  - trigger: ":ntab"
    replace: "0\t1\t2\t3"

Expands to 0 1 2 3, i.e. literal tabs between numbers in one field, not separate numbers entered into four fields. Espanso 2.2.1 installed via Homebrew on macOS Sonoma 14.4.1 (x86)

smeech commented 6 months ago

You may need to change the injection mechanism for the replacement. You haven't stated which program you're trying to use this in, but I need:

backend: Inject
inject_delay: 100

in an app-specific configuration that refers to a LibreOffice Calc spreadsheet, for example, to force it to traverse fields.

assholehoff commented 6 months ago

Thank you for the reply! I have attempted to get this to work with Firefox, Safari and qutebrowser.

Unfortunately, setting backend: inject, inject_delay: 100 and key_delay: 100 (tried various numbers of ms delay) makes no difference (other than the entire substitution going slower). I tried setting globally in defaults.yml and individually e.g. in firefox.yml, using filter_class: org.mozilla.firefox

So, for clarity, this is one of the browser config files:

filter_class: com.apple.Safari
enable: true
backend: inject
inject_delay: 100
key_delay: 10

And it still injects 0 1 2 3 4, only slower.

smeech commented 6 months ago

Which site are you trying to replace into? Google sheets, or another?

smeech commented 2 months ago

I think this thread has run off-topic, and we're running out of responses, so I'll close it. There are a couple of workarounds for injecting characters that Espanso can't handle here: https://pastebin.com/AA4Vmx0G