A very simple macro that I find myself using alot. I have it mapped to fn layer and the keys 7,8,9,0
For example if I hit fn + shift + 7
It will record all keystrokes until I hit fn + shift +7 again
And then I can “play” the keystrokes with fn + 7
ifShift recordMacro #key
ifNotShift playMacro #key
Thanks for sharing! What do you usually record and play back this way? Passwords?
I find myself repeatedly entering the same strings over the course of a work day. These typically vary from day to day so I can record them once in the mornings and save time over the course of the day.
I also have to do repeated actions in text files, do once, record, play back. Yes could probably do with regex and vim actions but I am not always in vim.
And occasionally passwords too!
Ok this is awesome. Thanks for sharing!
One small comment to get this working though: you need to enable extended macro commands.
To do this, create a macro called
$onInit which contains the following content:
set macroEngine.extendedCommands 1
I had assumed everyone had those on, but then again I have been using the “extended commands” with Karels firmware since I pretty much got the keyboard!
extendedCommands switch is will not be needed in next firmware version. Maybe already isn’t, not sure.
Right now it still is… I’m running the newest firmware version and it didn’t work without
I have yet to release a new firmware and Agent version.
extendedCommands will be enabled by default.
The great thing about “runtime macros” is, that you always have them because your UHK has them, no matter if the application you need has macros or not.
I want share my enhanced version of this macro, which allows you to repeat the macro until release.
The downside of this is that you need to create 2 macros, instead of only 1.
setReg 0 #key
ifShift recordMacro #0
ifNotAnyMod exec PlayRepeatMacro
ifNotReleased goTo @-1
Also, I have another macro with ‘recordMacroDelay’ command, which is really useful in many situations to add delays.
PS: Be careful with the repeat function, specially if the macro is long
Sometimes is overkilling!
Can’t you put it into a single macro by replacing
ifNotAnyMode exec PlayRepeatMacro with
ifAnyMod break and just adding the commands of the PlayRepeatMacro below?
Does anyone know how I can use a single key hold a layer and a shift key at the same time? I want to use it in the following way:
- if I use just the layer key, playMacro
- if I use this new special key (layer + shift), recordMacro
Is that what is not described in the OP?
I want to hold down a single key, and I want it to activate a layer and shift at the same time. The OP mentions holding down a layer key and a separate shift key at the same time.
Any alternative solution that achieves the same desired effect would also be fine.
What I’m getting at is:
- one dedicated key for recording runtime macros
- one dedicated key for playing runtime macros
yup, i used a layer key for all because I didn’t want to remap base keys
I see, thanks for the post! very handy indeed
Ty for this. This has been great for gaming. Because it’s a split keyboard it’s harder to reach keys like m, p, i from the left side, but I don’t necessarily want to permanently bind these keys to my key cluster module.
I did try the other script that allows for repeating, and it does work… up to a point. I find if I click the key a few times in succession I get a lot of issues, like it looping uncontrollably and causing programs to crash.
Is there a way for the macro to include typing delays?
Like @Tunney, I often am testing something where I need to do the same workflow repeatedly, which includes logging into something, typing a bit, waiting for something to load – I’d love to record a macro that runs in “real time”: that is, the macro is played back at the same speed as I recorded it. Right now, my UHK when replaying the macro just blasts the keystrokes out, which works fine for many things that do proper input buffering, but not for my use case.
I know pre-programmed macros can do delays, but I am hoping to get that working automatically.
Long story short, no.
There is the
recordMacroDelay command which allows you to manually record a delay when you know that it is needed at some place.
You also can globally slow down the output by setting keystrokeDelay to some reasonable value (something like 20 or 50?).
recordMacroDelay is perfect!
I have the usual runtime macro bound to 9 on the Fn layer (9 because it mirrors emacs and
C-x ( to start recording an emacs keyboard macro:
ifShift recordMacro #key
ifNotShift playMacro #key
Then, on Fn-8 (“8” rhymes with “wait”, and is next to 9…), I just have:
Let’s say I’m logging into a website. I do this:
- shift-Fn-9 to start recording.
- Enter my login credentials. Tab to the “log in” button, hit enter.
- Now I have to wait for the website to respond. I hold Fn-8 while that happens.
- When I’m logged in, I release Fn-8, and perhaps tab twice and hit enter to open the first item.
- Shift-Fn-9 to stop recording.
What’s great about this approach is that I can type slowly and carefully (so the macro is recorded correctly) when, say, entering my username and password, but that part of the macro plays back at full speed. So it’s actually in some sense better than what I asked for: the delays are exactly where I need them, and exactly the length they need to be.
Since no delay is introduced and nothing recorded when I’m not doing anything with the keyboard, I can also do something like this:
- when the slow part of the workflow starts, don’t do anything, just count to yourself to time how long it takes.
- when the UI is ready, then hold down Fn-8 for the same count to record the same delay. Release, and continue recording. The actual real-world time you were waiting – and during which the UHK was recording – was about twice as long as needed, but when playing back, only the Fn-8 delay time is used.
This is truly amazing. It’s life-changing. Now when doing repetitive testing or workflows I can record a macro and it’ll go soooo much faster.