I’m pretty new to Keyboard Maestro. So I have a list of 100 text commands, and I’m trying to get them to copy, paste and enter into a program one by one. However, when I did them individually, the code ran out of room really fast. It would be awesome if I could somehow make a variable that’ll run through the list or a way to have it go line by line down the list. I’m not really sure how to do this though, so if anyone could help me that would be great. I would really appreciate it. Thanks!
I think this should be fairly straight-forward if I understand you correctly.
Assuming the text commands are in a TXT file, you should be able to open the file in a text editor like TextEdit.
So I would suggest you start as follows:
Open the file in TextEdit
Using the keyboard, note the keystrokes to do the following:
- Go to the beginning of a line
- Select the entire line
- Copy the line
- Move the cursor down to the next line
You can create a KM macro to execute these steps using the “Type a Keystroke” Action.
You might just stop there for now, and try the macro.
Executing the macro will put the text line on the clipboard.
Switch to your program app, and paste.
If this works, you’re ready to add a few more steps to your macro:
Insert a Step at the top of your macro:
0. Switch to TextEdit using "Activate a Specific Application.
Then, ADD these steps at the bottom:
- Switch to your Program app using the “Activate a Specific Application”
(Note: you should have previously opened your Program app, and make it ready to receive a paste of the text command)
- Paste using the KM “Paste” Action.
This should get you started. I would test with text commands that don’t destroy/delete or add anything – maybe display something.
When you’re ready to execute the next text command, put your Program app in the state ready to receive a new command via paste, and execute the KM macro.
When you get it all working, you might share it in the “Macro” section of this forum so others can benefit for all of this.
Huh? What kind of text commands?
The code ran out of room? Where?
You’re pasting into a program? What program?
Please give us more info, so we can help you without having to guess at what you’re doing.
From you question I think I know what you want to do.
You have a list and want to process each line.
I have made a macro, which has a list saved in a variable.
Then a For each action, which processes each line of this variable.
Here is a video of the macro in action in TextEdit:
And here is the macro file:
Thanks so much, JimmyHartington! Is there any way to put a 5 second delay between each one?
Sure, use the Pause action.