4 ms·
I was wondering how this was done technically, i.e. how it gets the current text content, and how it would do the text replacement. From a quick glance, it loo
by albertzeyer 4y ago
I was wondering how this was done technically, i.e. how it gets the current text content, and how it would do the text replacement.
From a quick glance, it looks like for getting the text, it listens to all the keyboard events globally. I can imagine many potential problems and shortcomings with this approach, but on the other side, this is probably the most simple and most generic solution, working for almost every application.
For sending the text, it does sth similar, i.e. it just injects global key events. Probably first some key backspace events to delete the old text, and then the keys for the replacement text.
https://github.com/espanso/espanso/blob/dev/espanso-inject/src/mac/native.mm https://github.com/espanso/espanso/blob/dev/espanso-inject/s...
But maybe I understand the code wrong. I did not delve too deep into it.
- veidr 4y agoI think there is literally no other way to do this well. Maybe for some subset of applications and OS, it could work, but Espanso works with virtually everything on Mac and Linux. (Windows too I think but I don’t use it there.) It does require a high degree of trust, but otoh it is extremely useful. It is one of the most useful pieces of software I have ever used, so I’m willing to extend it a level of trust similar to my OS or password manager.
- federicoterzi 4y agoAuthor here :) You're pretty close! Espanso currently uses a combination of key injection + clipboard to get the best results. There are still some edge cases, but we are trying to solve them with other approaches, such as using custom Input Methods (the same mechanism used for some languages like Chinese)
- SaulJLH 4y agoAny plans for AHK support? v1, but esp. v2: https://www.autohotkey.com/ https://www.autohotkey.com/
- kamban 4y agoI have seen its codebase, and even took some inspiration for my Elephas app. The founder is an expert I can say.