auto typing when pressing a specific key?
hello,
i tried asking this on other subs but have had no success.
ive been searching for a way to create a script that when i press a specified key it will type said comment, regardless of the window.
so for example if i press F5, i would like it to press enter, then type "hello world"
so far ive tried, autotyper by muru, linux mint's autokey, autohotkey, either via crossover or wine. none of these seem to work or are able to accomplish what im looking for.
in the event that it matters, im using no DE, (only AWM).
About this post
- Posted
- Archived
- Score
- 2 · 100% up
- Kind
- Text
- ID
- 86fr27
7 comments
Try writing an
sxhkdrule that runsxdotool.Something like:
↑ Write that to
~/sxhkd/sxhkdrcand runsxhkd, then press F5 to test.If you want it to run when starting X11, put
sxhkd &in~/.xinitrc.hmm, its not working, for some reason its like it attemps to write but no output is typed.
basically it attempts to say hellow world when the key is pressed except it just flashes the cursor and then nothing is typed. almost as if the "return" is affecting it? if i spam press it, sometimes more letters come through but its vastly inaccurate. no idea why.
EDIT: so i tried removing the return and just left the 2nd line of hello world and it only ends up typing "rld". very strange
edit 2: so reading issues online and messing around i found that unless i increase the delay to a ridicules amount and type extra letters like "hhello wworld" only then it will work properly. but its still kinda terrible tbh. return just straight up doesnt even work.
I did some tests and it seems like xdotool does funky things when multiple invocations of it are used to type things in rapid succession, especially if some keys are already pressed at that time.
Here's a fixed
sxhkdrc:This works for me. The
@marker makes the command be run on key-up, so the held-down F5 key doesn't interfere. Multiple commands given to a single invocation of xdotool also don't interfere.