Score:0

Trying to transfer an auto hot script to Autokey but getting not defined

in flag

First I had a stroke so I learned to type from the middle of the keyboard with one hand. I use alt + k for example to hit return. Anyways this script I use for Windows Auto Hot Key.

!f::Send, {Tab}// alt + f = tab
!k::Send, {Enter}// alt + k = enter
!i::Send, {Backspace}// alt + i = backspace
!y::Send, {Up}// alt + y = up arrow
!h::Send, {Down}// alt + h = down arrow
!g::Send, {Left}// alt + g = left arrow
!j::Send, {Right}// alt + j = right arrow
!,::Send, {=} // alt + , = =
!.::Send {U+0060} // alt + . = `
!/::Send, {-}// alt + / = -
^,::Send, {[}// ctrl + , = [
^.::Send, {{}// ctrl + . = {
^/::Send, {(}// ctrl + / = (
^m::Send, {:}// ctrl + m = :
^n::Send, {$}// ctrl + n = $

I'm trying to do the same thing for Ubuntu Autokey. From the documentation, I tried a few different things.

 keyboard.send_key(enter, repeat=1)// NameError: name 'enter' is not defined
 keyboard.send_key(return, repeat=1)// NameError: name 'return' is not defined
 keyboard.send_key("enter", repeat=1)// nothing no error but does not hit enter.

Is there a key list I should be using because I can't seem to find it. Does anybody know what I'm doing wrong? I'm currently learning javascript from TOP so not trying to learn python atm. But I think I can pull it off with an example or two.

vanadium avatar
cn flag
Probably these are the key names for the Python: https://pyautogui.readthedocs.io/en/latest/keyboard.html#keyboard-keys
Score:0
cn flag

These are the key names for the Python: https://pyautogui.readthedocs.io/en/latest/keyboard.html#keyboard-keys

Your third attempt, keyboard.send_key("enter", repeat=1), is correct syntax. The reason it does not result in visible effects is because your system sees that Alt and k is pressed. Sending an "enter" causes applications to see Alt+Enter. Thus, first having the software "release" Alt may give the desired effect: keyboard.release('alt').

I probably would use xdotool rather than autokey for this function. A command such as

xdotool  keyup alt sleep 0.1 key Return

can easily be bound to Alt+K through your desktop's keyboard shortcut function, "Settings" - "Keyboard" in the default Ubuntu desktop. The small pause between releasing the Alt and sending Enter appears necessary, so if you stick with Autokey, you may also need to introduce a small delay.

Note that for any of these approaches, you need to be running X11. Recent versions of Ubuntu default to Wayland, but from the login screen, you can change to Xorg. For now, the availability of keyboard automation tools on Wayland is very limited.

Score:0
in flag

I figured out the answer, I guess you need the <> with "" marks for it to work. keyboard.send_key("<enter>", repeat=1).

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.