Programming A Macro

53 views
Skip to first unread message

Kelikaku Coutin

unread,
Feb 16, 2021, 6:06:55 AM2/16/21
to autokey-users
I have a keyboard that has a macro function, and when I tried to program it, the keyboard accepted the sequence, but it refuses to play back the sequence. That's how I discovered auto-key! I've been experimenting with it for a few days. Is it possible to program a complex sequence into the auto-key buffer?  Here's the sequence that I am interested in programming: 

→ [ALT]+F
↓ ↓ → [ENTER]
[ALT]+F
↓ ↓ ↓ [ENTER]
↓ → [TAB]
→ [TAB][TAB][TAB]↓
[ENTER][END]
[TAB][TAB][TAB][TAB]
[END] ←  ←  ←  ←
[BKSP]

Isn't there a way to write a script that can accomplish this? 

Thanks in advance! 

Keep up the good work.  בס״ד

Joe

unread,
Feb 16, 2021, 7:12:42 AM2/16/21
to autoke...@googlegroups.com
See https://github.com/autokey/autokey/wiki/Special-Keys .


delay = 0.1
keyboard.send_keys("<right><alt>+F")
time.sleep(delay)

...

Then you just have to split up the whole sequence into chunks the
receiving application can handle at one go and add delays between the
chunks because most applications can't respond as fast as AutoKey can
emit keyboard and mouse events. time.sleep(0.1) will probably be enough
delay for anything that doesn't make the receiving application think
about things too much.

Start with a very long delay (even a second or two) so you can see the
movements being performed one by one and see if any don't work as
expected. Then, decrease the delay until you're happy with the speed or
until something breaks.

Keyboard.send_keys() sends the string of its argument one
character/symbol at a time, but if you need a multi-key keypress, you
use a "+" between those keys as in <alt>+F.

You may be tempted to use keyboard.send_key() (without the "s" on the
end) if you need to send just one character. Don't do that unless
keyboard.send_keys() won't do what you want.

If you need to send any multibyte characters (like Hebrew),
keyboard.send_keys() won't do that without excessive machinations. Paste
them from the clipboard if at all possible.

Joe
> --
> You received this message because you are subscribed to the Google
> Groups "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to autokey-user...@googlegroups.com
> <mailto:autokey-user...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/0a1b7391-e3d8-4568-9f90-5df8d4ba7d91n%40googlegroups.com
> <https://groups.google.com/d/msgid/autokey-users/0a1b7391-e3d8-4568-9f90-5df8d4ba7d91n%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages