Add time delay for key strokes in type command#64
Merged
Evidlo merged 3 commits intoEvidlo:masterfrom Jul 17, 2024
Merged
Conversation
added 2 commits
July 11, 2024 15:58
…ing pynput. Added --duration and --delay argument to 'type' tool to allow users to set key stroke duration and time between key strokes.
Owner
|
I like the idea of adding --delay and --duration arguments, but I think the functionality ought to be upstreamed into pynput instead of doing the sleep ourselves.
…On July 11, 2024 9:18:55 AM CDT, Xaver K ***@***.***> wrote:
I have been having the issue lately that single characters got lost when using `type` via a keybinding.
Especially web-interfaces seem to sometimes be too slow to register very short key presses.
E.g. instead of my username `klemenschits`, every third time or so it would only register `klemnschits` or `klemenshits` (the second one really hurts :sweat_smile: ). It is actually worse for passwords, because they are basically wrong at random.
Testing around, I found that this does not occur using the `--xdotool` flag.
The reason seems to be that xdotool uses a default key press duration of 12ms (see [1]).
I thought it would be useful to have the same behaviour using the pynput implementation and make it a command line flag. Testing this showed that with increased key stroke duration, it now works every time. Since this is not really easy to test, I cannot give a 100% guarantee that it now works every time, but it seems reasonable to me.
I have set the default to 12ms per keystroke (like xdotool), but I am open to change that default if there is a more reasonable one.
Curious to hear what you think :slightly_smiling_face:
[1] https://askubuntu.com/questions/1098762/does-xdotool-key-delay-pause-for-specified-delay-between-typing-every-two-co
You can view, comment on, or merge this pull request online at:
#64
-- Commit Summary --
* Added type_string helper function to type strings with time delays using pynput. Added --duration and --delay argument to 'type' tool to allow users to set key stroke duration and time between key strokes.
* Updated manual
-- File Changes --
M MANUAL.rst (4)
M passhole/passhole.py (36)
-- Patch Links --
https://github.com/Evidlo/passhole/pull/64.patch
https://github.com/Evidlo/passhole/pull/64.diff
--
Reply to this email directly or view it on GitHub:
#64
You are receiving this because you are subscribed to this thread.
Message ID: ***@***.***>
|
Contributor
Author
|
Good point. It is probably better to do this upstream. There seems to be an open pull request on pynput [1] about this issue for 7 months now. It did not gain a lot of traction and I could not find a related issue, so not sure how long it will take to merge this. So either wait, or use the custom implementation for now and then switch to the pynput functionality once it is merged. I added an issue in pynput to implement this, let's see how it goes : moses-palmer/pynput#606 |
Owner
|
Thanks for putting the legwork in. I'll keep an eye on the pynput issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have been having the issue lately that single characters got lost when using
typevia a keybinding.Especially web-interfaces seem to sometimes be too slow to register very short key presses.
E.g. instead of my username
klemenschits, every third time or so it would only registerklemnschitsorklemenshits(the second one really hurts 😅 ). It is actually worse for passwords, because they are basically wrong at random.Testing around, I found that this does not occur using the
--xdotoolflag.The reason seems to be that xdotool uses a default key press duration of 12ms (see [1]).
I thought it would be useful to have the same behaviour using the pynput implementation and make it a command line flag. Testing this showed that with increased key stroke duration, it now works every time. Since this is not really easy to test, I cannot give a 100% guarantee that it now works every time, but it seems reasonable to me.
I have set the default to 12ms per keystroke (like xdotool), but I am open to change that default if there is a more reasonable one.
Curious to hear what you think 🙂
[1] https://askubuntu.com/questions/1098762/does-xdotool-key-delay-pause-for-specified-delay-between-typing-every-two-co