Hello Maestros!
In my journey to be a stronger/wiser/more efficient user of Keyboard Maestro, I go back to many of my older macros and reconfigure/rethink them with better/slicker techniques that I've learned from this forum and from reading the wiki. There is a ton that I don't know even though I've been at this for a while. I was inspired by @JMichaelTX's post, several days ago, when he asked "What is the Best Method to Prepend a Few Lines of Text to a Large File?." At first, I was like "Hell, other than @peternlewis, @gglick, @DanThomas and a handful of other KM superstars - (shrug) I can't help him! - He knows much more than I know about KM and programming than I could help him with." I waited a day and since no one responded, I showed him how I had done it in hopes others would chime in. I figured, people had the same thoughts about helping him as I did or maybe they were afraid. I also thought, I help others, without delay, so why not throw my hand in the pot. What is he gonna do, ban my solution? Anyway, I posted because as great a KM problem solver and Maestro that @JMichaelTX is, sometimes you just want another opinion. After that, others chimed in with great options. I was happy to break the ice.
Thinking about it later, I wonder if he had a technique that he just wanted to improve on.
Flash back -- I remember a few months ago, @gglick taught me how to select macros, using a prompt list, from a specific macro group. That technique changed 8 of my macros and boosted the efficiency tremendously.. I still owe Gabe a few beers for that one. I've never had or bought alcohol but his help was worth it.
That brings me to today. I have a working macro with nothing wrong with it functionally. It works just as I need it to. I just think there are other techniques, that can be implemented, to make it better and to add to the toolkit. The implementations would help me and others with future macros.
This macro is used for a specific meeting preparation, for work, when using Citrix. Long story but even cutting and pasting won't work for the back and forth.
The Macro does the following:
- Allows the selection of data (in this demo’s case, there are 4 selections associated with the macro. The real one has more) using the OCR feature and stores it into a local variable.
Sample data:
CHR0384757: Make cookies
CHR03848357: Make a smoothie
CHR0386657: Bake a cake
CHR0381457: Start veggie stir fry
-
After each selection, it will provide a 3 second grace period to select the next line of data. The delay is in case I have to scroll down to another page. As mentioned, each selection saves to a local variable.
-
Once completed with all four selections, the macro will type the output in a text document. (However, in this demo, it will display in a window)
The simple output looks like this even though it would be in an added to an ongoing work journal:
Meeting Title: Review
Logged: Wednesday, July 22, 2020 @ 3:24 PM
========================================================================================
Check
========================================================================================
CHRO384757: Make cookies
CHRO3848357: Make a smoothie
CHRO386657: Bake a cake
CHRO381457: Start veggie stir fry
========================================================================================
That said, I want to know how I can do any of the following concerning the attached macro above. Take a look and please, please, please comment if you have time or suggestions.
My ask --- Here are the specific areas that I'd like to improve:
- Improve on the efficiency of steps/code.
- Can the variables, in the macro be dynamically created -
Local_CR1 - Local_CR4
or even up toLocal_CR10
? In this macro there are 4 macros with the following sets. Basically, can a For Each action be created to reference a list of Local_CR variables 1 - 10 to plug into OCR save to variable area? Or do I have to declare the variable as I've done. - I know there is a Repeat action and other looping actions but could this be done better.
- Any other specific techniques you would employ to make this better?
Snapshot of the actions in question - please expand the macro to see the same steps for the other variables:
Basically, I'd just like to know how I can make this more efficient and/or what would you do differently?
Sorry for the long post and Thanks for your time.
P.S. - Don't be afraid to please chime in!
KC