Your full service technology partner! 
-Collapse +Expand
Search Delphi Group:

-Collapse +Expand Delphi To/From
-Collapse +Expand Delphi Store

Prestwood eMagazine

December Edition
Subscribe now! It's Free!
Enter your email:

   ► KBProgrammingDelphi for W...Tool Basics   Print This     
  From the March 2016 Issue of Prestwood eMag
Delphi Tool Basics:
Record Keystrokes
Posted 13 years ago on 12/12/2008 and updated 3/3/2009
Take Away:

You can record a series of keystrokes to be played back for quick changes in code. Use Ctrl+Shift + R to begin recording, Ctrl+Shift+R again to stop the recording, then Ctrl+Shift+P to play recording.


You can quite easily record a series of keystrokes to playback over and over, making changes to data and code quite quick. I have often used this feature in Delphi, even for changes I need to items outside of Delphi, like data or an article. The keystrokes are logged exactly as you enter them, so be careful, make sure the recording you are making is for a repetitive job.

Okay, so stop talking and tell me how I can use this neat feature. Okay, I will.


Say you have a series of lines as below:

sSomeString1 := qryWork.FieldByName('myField1').AsString;
sSomeString2 := qryWork.FieldByName('myField2').AsString;
sSomeString3 := qryWork.FieldByName('myField3').AsString;
sSomeString4 := qryWork.FieldByName('myField4').AsString;
sSomeString5 := qryWork.FieldByName('myField5').AsString;
sSomeString6 := qryWork.FieldByName('myField6').AsString;
sSomeString7 := qryWork.FieldByName('myField7').AsString;
sSomeString8 := qryWork.FieldByName('myField8').AsString;
sSomeString9 := qryWork.FieldByName('myField9').AsString;
sSomeString10 := qryWork.FieldByName('myField10').AsString; you wish to change each of these lines and put an "X" in front of each of the numbers. You cannot use find and replace as each number is different. You could just cursor through, up and down, but with a recorded macro, just do it once and play it back over and over.

  1. In this example, put your cursor at the beginning of the first line.
  2. Now, hit Ctrl+Shift + R (for begin Recording)
  3. Right arrow over to so the cursor is to the left of the first number (1) and type an "X"
  4. Right arrow over again to the next number (1) and put another "X"

Almost done.

  1. Now, hit the down arrow and then the Home key. This will put the cursor at the start of the second line.
  2. Hit Ctrl+Shift+R again to stop the recording.
  3. To Play the recording, hit Ctrl+Shift+P

The keys you hit will be played back and the same changes you made to the first line, will be made to the second line.

You may hold down the Ctrl+Shift+P for faster repeats.

Now, if you use my example, you will notice, the second "10" on the last line will actually be incorrect. This is because when you recorded the arrows, it recorded only a certain of right arrow key presses. Because "10" had the extra character, the zero, the "X" ended up being to the left of the "d", instead of after the "d". So make sure  the keystrokes you make in the recording will work each time you play it back or you may get unexpected results.

Now, FYI, you can record pastes, page ups/downs, inserts, deletes and so on, so play around with it as it has saved me much typing over the years.



Share a thought or comment...
Comment 1 of 1

Hi Daniel,

Thank for this useful hint. Can you precise what version of Delphi is this intended for ?

Posted 12 years ago
Write a Comment...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.

Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P195A1
Enter key:
KB Post Contributed By Daniel Kram:
Visit Profile

 KB Article #101686 Counter
Since 12/12/2008
Sales Website: Or visit our legacy sales site:

©1995-2021 Prestwood IT Solutions.   [Security & Privacy]