Is there a way to record a macro, then play the macro a certain number times (without reapeatedly smashing the PlayMacro button)?
For example, vim has a command that’s like, 99@q
or something that plays the q
macro 99 times.
Is there a way to record a macro, then play the macro a certain number times (without reapeatedly smashing the PlayMacro button)?
For example, vim has a command that’s like, 99@q
or something that plays the q
macro 99 times.
I map the below to keys 1 to 0 on a layer. It stores a numerical value in a variable ‘repeatCount’
if($thisKeyId == 65) setVar thisKeyValue 1
if($thisKeyId == 66) setVar thisKeyValue 2
if($thisKeyId == 67) setVar thisKeyValue 3
if($thisKeyId == 68) setVar thisKeyValue 4
if($thisKeyId == 69) setVar thisKeyValue 5
if($thisKeyId == 70) setVar thisKeyValue 6
if($thisKeyId == 00) setVar thisKeyValue 7
if($thisKeyId == 01) setVar thisKeyValue 8
if($thisKeyId == 02) setVar thisKeyValue 9
if($thisKeyId == 03) setVar thisKeyValue 0
setVar repeatCount ($repeatCount*10 + $thisKeyValue)
if($thisKeyId == 06) setVar repeatCount 0
I then use this variable in one of the record/play pairings I have. Simplist one is:
Record the macro:
recordMacro $mouseMacro
Play the macro the set number of times:
if($repeatCount == $zero) setVar repeatCount 1
playMacro $mouseMacro
setVar repeatCount ($repeatCount - 1)
if ($repeatCount > 0) goTo 0
Wow, this sounds like exactly what I’m looking for, but can you please explain the script and execution process a little more? Just looking at the script, I don’t understand what is the 65, 66…00, 01 etc. Are these the hard coded keyID for numbers 1 to 0?
If you press Layer+6, it repeats 0?
From my understanding, the first code block just sets the number of repeats by assigning a number to the repeatCount variable, then the last macro plays the macro that many times. So, how does it work if I want to run 99 repeats? Just press Layer+9, Layer+9, PlayMacro(last codeblock)?
The values 65 66 etc are the keyIds that identify the pressed keys. The keyIds line up with the values being set in the macro to thisKeyValue.
So if you map this to 1-0 on mouse then hold mouse and press 9 twice you will set repeat count to be 99
Then when you play the macro it will repeat 99 times.
From a readability standpoint, it’d be nice to feature key names in the macro instead. I don’t know the alternative syntax off the top of my head.
I probably need to modernise my macros for more modern syntax! Some of them are very very old.
i’ve modified the script to display the current numerical value in the segment display at the top:
Pressing keyId 06 (standard position backspace key) resets the display.
Macro repeatValue
if($thisKeyId == 65) setVar thisKeyValue 1
if($thisKeyId == 66) setVar thisKeyValue 2
if($thisKeyId == 67) setVar thisKeyValue 3
if($thisKeyId == 68) setVar thisKeyValue 4
if($thisKeyId == 69) setVar thisKeyValue 5
if($thisKeyId == 70) setVar thisKeyValue 6
if($thisKeyId == 00) setVar thisKeyValue 7
if($thisKeyId == 01) setVar thisKeyValue 8
if($thisKeyId == 02) setVar thisKeyValue 9
if($thisKeyId == 03) setVar thisKeyValue 0
setVar repeatCount ($repeatCount*10 + $thisKeyValue)
// Display logic
if($repeatCount > 999) {
setLedTxt 0 "+++"
}
else {
setLedTxt 0 $repeatCount
}
// Reset functionality
if($thisKeyId == 06) {
setVar repeatCount 1
setLedTxt 1 ""
}
Macro repeatPlay
if($repeatCount == 0) setVar repeatCount 1
// Display current count before execution
if($repeatCount > 999) {
setLedTxt 0 "+++"
}
else {
setLedTxt 0 $repeatCount
}
playMacro $mouseMacro
setVar repeatCount ($repeatCount - 1)
if ($repeatCount > 0) goTo 0
// Clear display when done
setLedTxt 1 ""
I love the addition of the LED text!