I play a solitaire game on my Mac regularly. It includes a command to auto move that I will use when I know I won the game and don't want to click all the waiting cards one at a time. Holding down command-A finishes the game for me so I can log it into my statistics. The problem is I like having my keyboard repeat and pause rate set fast, which is too fast for the game, it can't keep up after moving two cards.
At first I thought to do some kind of loop with KM to stop at a point, but I couldn't find an Action that looked right. I also realized the game did not use proper dialog boxes that an Action could read. So I decided instead of taking a lot of time, I would try a simple Repeat Action.
I set it for 20 repeats of command-A, but that was too few when I win a game early with lots of cards to move, so I changed it to 50. One thought I had was what would happen if I won late in the game when only a few cards needed to be moved. I tried it with 50 and discovered that even though KM continues to send the command, I could still log the win and quit without any consequence. So far 50 is working.
I'm happy I didn't spend too much time trying something complicated when something simple worked.