Macro recorder for Mate SOLVED

Hi, Can someone recommend a way to automise text input. like email addresses? Autokey doesn’t work correctly. I can only get xmacro to work in terminal - I tried linking the " xmacroplay “$DISPLAY” < yourfile.txt " command with a key shortcut but this has no effect either in terminal or elsewhere.
Latest Mate v. on odroid xu4 with emmc boot.
Thx!

Have you tried xdotool?

sudo apt install xdotool

I use it as a way to remote control my UMate PC TV: https://github.com/gabdub/gpie-remote

That looks interesting, thanks. But unfortunately I am not a programmer - can’t find comprehensible tutorials - do you have a typical example for email address entry in e.g. firefox? Cheers!

To type a fixed string in the current active window, you run the command:

DISPLAY=:0 xdotool type "[email protected]"

If you try this in your terminal, you’ll see that [email protected] is typed and if you press [Enter] you get an error (the command [email protected] doesn’t exist).

You can put this line inside a bash script file (add “#!/bin/bash” as the first line, without the quotes, and make the file executable). Then assign this script to a keyboard shortcut. Every time you press that key, the fixed string will be typed in the active window.

I’m not sure if this is what you’re looking for, though.

EDIT: you can also type special keys and move the mouse. Some examples in https://github.com/gabdub/gpie-remote/blob/master/webscripts/dowebcmd.sh

If your needs are only in the browser, and you use (or can switch to) Chrome, there is a plug-in that works very well for me. ChromeAutoTextExpander (https://github.com/carlinyuen/ChromeAutoTextExpander) I like this because, since it works within the browser, it’s cross-platform.

I also use AutoKey-gtk for when I need something outside a browser window. It works anywhere and can be obtained via the software center or by typing this at the command line:

sudo apt update && sudo apt install autokey-gtk

thx, the extension works, but autokey does not.

Thx. I got it working in Terminal but assigning keys resulted in no effect. The script file is myscript1 and looks like this (as you wrote):

#!/bin/bash
DISPLAY=:0 xdotool type "[email protected]"

The command I entered into keyboard shortcuts is:
./myscript1

I used an unassigned kb combination (at least in the list it doesn’t exist) and tried executing in a browser and text editor and nothing happened.

Any ideas?

I think you should use an absolute path in your keyboard shortcut, like:
/home/user/myscripts/myscript1

And, just in case, inside your script too:
DISPLAY=:0 /usr/bin/xdotool type "[email protected]"

you can run:
which xdotool
to see where xdotool is installed.

EDIT: also don’t forget to make the script runnable with “chmod a+x”

tried all this as well as using xbindkeys but nothing.
Key shortcut custom works for starting apps though

Trying it at home I found that the issue is related to run xdotool while the keyboard shortcut is “still pressed”.
Adding a delay in the script do the trick for me:

#!/bin/bash
sleep 0.3
DISPLAY=:0 /usr/bin/xdotool type --delay 10 --clearmodifiers "[email protected]"

You can adjust the sleep delay to a value (in seconds or fraction of seconds) that is higher than the time you keep the shortcut keys pressed (you must release all the modifiers).

The parameter --delay adjust the speed of typing and --clearmodifiers force to release all modifiers like shift or control to ensure the text is typed without them, but keep in mind, that if you keep some modifiers pressed and release them after the script has run, the system will think that the modifiers are kept pressed!

You can also activate a window before typing, for example:
DISPLAY=:0 /usr/bin/xdotool search --onlyvisible --name “Mozilla Firefox” windowactivate key --delay 50 --clearmodifiers F5

Thanks a lot! It is finally working!

1 Like