New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Phrases are sometimes incorrectly expanded, missing character(s) #151
Comments
I'm facing a similar issue when I try to expand a phrase at the start of the line (v0.94.1 installed via pip). Steps to reproduce:
For example foo --> foobar Then you type foo, you will be left with ffoobar (first character of replacement phrase doesn't get replaced) and sometimes a newline is added to the end of the replacement text even though there is no newline in the actual replacement text configured in autokey. (I verified that) This is happening with both Ctrl+V and keyboard replace methods. |
I tried to reproduce it and failed.
I suspected that it might be some performance issue: The editor chokes when autokey presses the backspace key and loses keystrokes (because the javascript used in the web editor is slow), which result in incomplete operation and leftovers at the beginning. Please start autokey in verbose mode (--verbose or -v switch on the command line), trigger a phrase and look at the output. It outputs a lot of stuff, but there are entries like when triggering a phrase:
In my example, triggered the phrase »abcdef« using the abbreviation »foo«. Another thing you could try:
Example output, replacing »foo« with »abcdef«:
|
@ggada I also sometimes sometimes get your @luziferius thanks for the fast feedback 👍, digging in with
... I'm not sure: the issue isn't only happening in heavy webapps full of js potentially reacting slowly to input; I get the problem also in a terminal or Sublime Text. |
@luziferius well, my memories were wrong: I'm able to reproduce the problem in heavy-on-keypress contexts (e.g. the Firefox URL bar, or a webapp), but not in a terminal on Sublime Text. And I tested What can we do from here? Could you guide me to a delay-between-keysends patch I could test for a while? |
The time values need some tweaking, but should prevent heavy javascript apps from choking on fast input. This fix will lead to bad performance, as it slows AutoKey down considerably. (Maybe factor 100?) This needs a proper fix, like a user-configurable blacklist of bad applications, and only slow down for those applications. (Link commit with github issue: autokey#151)
@ronjouch Thank you for checking back on this. You can either checkout my testing branch (here: https://github.com/luziferius/autokey/tree/phrase_expansion_timing_issues_test, use git to fetch the branch or download as a ZIP archive), or edit the source files directly and apply the fix yourself. Either way, you may want to tweak the delays used, because I just guessed some arbitrary value. |
@luziferius 👍, testing this in the next few days on my machines. @ggada ping, maybe you want to give it a try too. |
@luziferius feedback:
|
But each one uses the typing approach to delete the trigger text using the backspace key. Maybe some other approach is more fruitful, like pressing Which pasting mode do you use? I suspect your phrases use the |
@luziferius yes, all my phrases expand using
Regarding
|
I think, opening two issues is sensible, so go ahead.
I’ll see if I can come up with a fix (at least fixing the clipboard issues), but I have no experience with low-level X11 stuff, so I can’t promise anything further. |
@luziferius thanks for the express crash fix! And here's #153 regarding restoring clipboard contents. |
The problem still exists. In some heavier applications (Thunderbird, LibreOffice) the keyboard entry method is not deleting the trigger text completely and mixes up the order of the input text. My workaround so far: I replaced phrases by scripts. For each script I disabled "remove typed abbreviation". Instead I send my desired output text and the length of my trigger text (X) to a function. This function first hits backspace X times with a delay in between. Then it iterates through my output text, also with a delay between each keystroke. "time.sleep(0.01)" works just fine for me. It works, but it's not that convenient since I have to enter the length of each trigger text manually. Maybe it would be useful to have an adjustable delay as a global feature? Maybe in global settings? This would help a lot. |
The time values need some tweaking, but should prevent heavy javascript apps from choking on fast input. This fix will lead to bad performance, as it slows AutoKey down considerably. (Maybe factor 100?) This needs a proper fix, like a user-configurable blacklist of bad applications, and only slow down for those applications. (Link commit with github issue: autokey#151)
The time values need some tweaking, but should prevent heavy javascript apps from choking on fast input. This fix will lead to bad performance, as it slows AutoKey down considerably. (Maybe factor 100?) This needs a proper fix, like a user-configurable blacklist of bad applications, and only slow down for those applications. (Link commit with github issue: autokey#151)
Here is my experience - hopefully it helps: LibO"iban" creates 3 different solutions: "sgdh" reliably expands to: Evolution"sgdh" produces: "mdfg" goes to: FirefoxIn FF these results: sge -> I closed #189, which contained this info. |
I’ll drop my plan for this issue here, to keep you informed. In this comment #151 (comment), I proposed an experimental patch that slows down autokey. I’ve rebased/updated the branch to the latest git master, so you can try this patch by yourself. The result was that it doesn’t really help. According to @ronjouch, it feels super slow and choppy. It improves the accuracy, but not up to 100% with the sleep time values used in it. Having a globally slow autokey, just to comfort some applications is a bad thing. So my plan on this is as following:
This allows adding as many “workarounds” as needed for specific applications, but does not slow down autokey in general use. |
Same issue in VScode, here. |
have same issue since years. Pretty much as @herrdeh described it and with different results/outputs. Very often in Firefox. |
Same issue here: |
I don't know if I can solve this, while retaining acceptable expansion speed. I think it is caused by the receiving application choking on fast input. Use short abreviations and the clipboard pasting where possible to work around this issue. |
I would be much happier if the expansion is slower, but correct. Because I spent more time manually checking every character of the expansion. And sometimes my manual checking is not correct.
|
You can try to run AutoKey from this https://github.com/luziferius/autokey/tree/phrase_expansion_timing_issues_test feature branch in which I added some sleeping between key presses. This is the full diff against the current develop branch, showing the whole change: (Well, technically, it also contains these bug fixes when compared against 0.95.4) You can download and extract a ZIP from the first link or just clone my fork and
Please report back, if you found some time values that work reliably on your pc. Edit: This branch implements roughly the same thing as that type_slow function you quoted. |
I found a temporary workaround that works in >80% of my current test cases (which is a big improvement). If there is a significant change in these initial statistics, I will report it. Use the type_slow() function from https://github.com/autokey/autokey/wiki/Scripting#function-to-type-text-slowly . Might be worth to add it as a standard autokey function, so that the user does not have to defined it in every script. My tests were with delay=0.01 in Firefox.
Update: I get also similar results with delay=0.005 |
Hm, my initial tests with type_slow() were mostly good (as described above), but now I still receive enough incorrect expansions to not be satisfied, even if there is longer delay=0.1 (see the gif below expanding 'brff' to a 'Best regards, \nFirstName FamilyName'). The delay delays the typing of the text characters, but the first abbreviation character 'b' is not affected by this delay. @luziferius does feature branch delays also the deletion of the abbreviation? That might be one of the issues. |
I tried this one as well
Looks like this on my Autokey: My machine goes crazy with it - the app on which i tried to launch it gets blocked. |
It seems that a single line has a higher likelihood of success than multiple lines. I've been experimenting with populating the clipboard and then pasting it, which seems much more reliable on my end. date_string = system.exec_command("date +'%A, %B %d, %Y'")
output = """## %s
*foo*:
*bar*:
*baz*:
""" % date_string
clipboard.fill_clipboard(output)
keyboard.send_keys("<ctrl>+v") |
It is weird. On my old Dell E7470 with latest Kali Linux I do not have this problem in any of the applications. Any progress finding out how to fix this? |
Will we see any progress on that some time? |
So far I solved this problem disabling in KDE Neon libreoffice-kde (and this worked). |
Hello all, I've got the same problem (Ubuntu 20.04, GNOME Shell 3.36.1). For me it's usually the first character of the abbreviation that is left over (as described in some cases above). Would love a fix for this! |
I'm not a developer, but my understanding of this issue is that solving it, if possible, would require a major rewrite of that portion of the code. Just use Paste using clipboard with your phrases and in your scripts. That almost always works. |
Yes, I confirm what said @josephj11 |
I face the same problem. Now changed all phrases to use If the only reliable option is @DoctorSubtilis are you confirming that @josephj11 Why would the change be a major rewrite? I seem to remember from the past that sending the characters was implemented at several places in the code. Is this now unified to one place? If yes, I assume only this part needs to be changed, plus the UI. I also assume that implementing the UI change is a bigger effort, so what about just skipping it for now and read the delay parameters from the configuration file which we have to edit with an editor? |
It is a problem with ibus Simply try: and try again in Firefox You're welcome... Now can someone please fix it? : Thanks, |
@miskovics: sure! |
@miskovics I don't know the source code. I have very limited knowledge of Python. I am just recalling comments from developers. We can't just remove an API call or even make it a dummy call to another one without potentially breaking a lot of user scripts. I did post on Gitter, suggesting that Paste using Ctrl+v be made the default option for new phrases, but didn't get much traction. I've almost never used shift+insert. Never needed it. We do need more than one method though. E.g.: Most terminals use ctrl+v for something else and insert with ctrl+shift+v. Given the diversity of Linux, there are almost certainly other edge cases out there. Yeah. Characters aren't being sent from just one place in the code. There's a weird difference between the behavior of keyboard.send_key() and keyboard.send_keys() that was just noted on Gitter. keyboard.send_key() doesn't seem to honor shifted characters like |
API: as much as I can see, the AutoKey API (https://autokey.github.io/lib.scripting.Keyboard-class.html#send_keys) does not let a programmer specify which method is used to send the characters. BUT even if it was possible to specify the method via the API, we could still hide this configuration option from average users in the GUI and keep the APIs powerful, as they are, for the experts --> no confusion for beginners, plus scripts are still working as before. Shift+Insert, ... : as much as I know, CTRL+SHIRT+v works everywhere, also in terminals. You are, of course, right about Linux's diversity, but then this would also mean that we just can't prepare for whatever might come in our direction. Maybe even the current options would not cover those special use cases popping up in the future, unexpected. --> we could just stick to CTRL+SHIFT+v, hide the configuration option in the GUI, and still have it in the configuration file for the experts. --> leaner UI, still same power. Is this then an ibus-daemon, a Firefox, or an AutoKey bug? |
@miskovics What I meant was that your use of the API determines the method used. If you use the Using the API is essential for almost all scripts. It's the only "simple" way for a script to talk to the active window. You could write a script that interacts with your system in another way, but that would need to use something like the The only place This option is only relevant when configuring AutoKey phrases. In a script, you have to code the API calls explicitly and can choose whatever works for the problem at hand. The future: If something new does come along, a large part of the desktops and other system utilities are written in Python, so Python will support whatever it is for their sake and we will come along for the ride because our scripts are written in Python and can access whatever they dream up. Where it gets dicey, is when they want to replace X11, which we rely upon, with something new like Wayland. Currently, we do not support Wayland and have a help wanted issue open for anyone who would like to try to fix that. |
@miskovics I can only guess that it is:
But I have no clue how ibus works, I only found out how to make autokey working again |
Same issue for Ubuntu 20.04 with Gnome writing into VsCode. |
Same issue for Ubuntu 20.10 with KDE |
If you run into this, use Paste using clipboard (Ctrl+V) with phrases. (But it can't do things like phrase macros.) If that doesn't work for you, you'll be stuck writing scripts that emit events slowly, one at a time, with delays in between them. See my type_slow() function for an example. This is a longstanding bug and I don't think anyone knows how to fix it, so we may have to live with it indefinitely. |
i have found that terminating the ibus-daemon makes things very much more consistent for me on Ubuntu 20.10 (same on 20.04). Sadly, I have to run my local startup scripts outside the regular startup process, to make sure the ibus-daemon is dead before auto-key starts. # kill ibus
killall ibus-daemon
# now start apps that struggle with ibus
NOHUP_OUT=${HOME}/.nohup.out
rm ${NOHUP_OUT} || true
nohup autokey-gtk >> ${NOHUP_OUT} & I have a couple of other keys that go whacky when the ibus-daemon goes away (copyq, flameshot), and I start those up the same way. I've been running this for months now and things have been pretty solid. Just switching to a new laptop I started having issues again, so I'll be sticking with this approach. |
@opennomad Thanks. I'm not familiar with ibus. I did a little poking around and it looks like it's not doing anything on my system (kubuntu 18.04):
|
cross-posting my observation from #596 : I set I can't remember if this has already been discovered, but it seems with superfast keyboard emulation typing there is not enough time for entering keycombo characters like Expected: the tool I use to diff the results: convertonline.io/url/diff |
"type_delay": 0.3 is the quickest that works for me (2.50GHz × 8 i7 at 80..150% (load: 7..14) + 32GB RAM, SSD) this workaround is by definition so slow that with longer autocompletes I might aswell go make coffee while I wait, which kinda negates the point of using text files to copypaste stuff from vs Autokey. has there been any other alternatives to slow typing? I tend to use my computer at its limit and other apps need 10x more load to start acting weird :| |
@allanlaal Some notes: Paste using clipboard (Ctrl+V) doesn't work for you? Since you're not using an EN-US locale/keyboard, you are probably using a Unicode character set that our keyboard methods won't process correctly anyway. Are you using my type_slow() function or some other code? Does this problem occur for you in all applications or just in some? Usually, we see problems like this with LibreOffice and the Firefox address bar, but most other applications, especially simpler applications like terminals and plain text editors tend to work fine. If this problem is persistent for you, you might want to try running xdotool from within an AutoKey script. xdotool (and the associated Python xdo module) uses a different API/library than we do, so sometimes it will have better results. |
I'm thinking of closing this and #380 as won't fix because the workarounds almost always work and no one has been able to figure out a solution in over four years. Also, if we are able to change to new input/output methods to accomodate Wayland, this would have to start over anyway. Any thoughts? |
Yes to both. Although Ubuntu 18.04 isn't at EOL yet, it shipped with AutoKey 0.90.4 and each of these issues are about AutoKey 0.94.1 and AutoKey 0.95.10. |
Classification:
Bug
Reproducibility:
Sometimes (fails ~ 30% of the time)
Summary
Phrases are sometimes incorrectly expanded, missing character(s).
Steps to Reproduce
myname@gmail.com
m@g
, with options:Expected Results
m@g
should expand tomyname@gmail.com
Actual Results
m@g
sometimes correctly expands tomyname@gmail.com
(~ 70% of the time), but sometimes fails to do so, missing one or several characters and expanding to for examplemynme@gmail.com
ormyname@mail.com
ormyname@gmail.c
.Version
autokey-gtk 0.94.1
Installed via: PPA
Distro: Ubuntu 18.04 LTS, fully up-to-date, running Xorg.
Notes
No workaround found
The text was updated successfully, but these errors were encountered: