Explore Categories

 

 PDF

Key Recording, Playback and Triggering Keys

The recording and playback features will allow the developers to record all the keyboard keys and later play/replay them, as and when required.

This will help the developers to automate and replay certain keystrokes repeatedly during testing of the code for various performance testing needs, as well as while debugging a project and automate multiple steps required to do the needful.

The steps to get the Key Recording done are:

  • Start the Recording
  • Navigate through the sequence of key strokes
  • Dump the Recorded information
  • Stop the Recording

The dumped recorded information when opened in Textpad, is as shown below:

As seen in the figure, the macros are appended to the file macros.log within the application path. Comma-separated Keys are written in the file against each macro name separated with the separator symbol specified while dumping the macro from the memory to the file.

Splitting of Macros

If the Macro gets recorded beyond 4000 characters, the Function $$FileRead cannot read further, which means that Keys beyond 4000 characters cannot be played back.

Hence, the Macro Recording capability has been enhanced in such a way that after recording 4000 characters, a new macro gets created automatically, and the subsequent keys are recorded in the new macro. The new macro will bear the same macro name, with a number concatenated to it. All the Macros created will be dumped in a single file, and replayed when required. Thus, n number of macros can be recorded in a file, read and played back.

For example, if the Name of the Macro is Testing, then after every 4000 characters, a new Macro is created with the Name Testing-1, Testing-2,…Testing-n. Thus, there is no limit to the number of characters which can be recorded, read and played back.

Commands Used for Key Recording and Playback

The following Calculator Pane Commands are supported for Key Recording and Playback:

Record Mode

Record Mode gives various commands to help the developer in recording keys. The mode should be set by specifying the mode as Record.

Syntax

MODE : Record

The following commands can be specified in the Calculator Pane once the Mode is set to Record:

Start

This command is used to start recording a macro.

Syntax

Start[:<Macros name>]

Where,

<Macros name> is the name assigned to a macro. In the absence of a Macro Name, it defaults to the name Macro.

Example

START : BSView

Replay

It is used to replay the recently recorded macro from the memory, but before the same is dumped into a file. If the macro is already dumped into a file, the same is cleared from the memory and will not be available for Replay. The macro from the file can then be replayed using File I/O Approach and Action ‘Trigger Key’ (explained later), but cannot be replayed through Calculator Pane.

Syntax

REPLAY

Pause

This command is used to pause the recent recording.

Syntax

PAUSE

Resume

This command is used to resume the recently paused recording.

Syntax

RESUME

Dump

This command is used to dump the recording to the file macros.log. The macro name will be separated from the keys with the ‘separator character’ specified as the parameter. It also clears the keys in memory.

Syntax

DUMP[: ~]

 

Stop

This command is used to stop recording the recent macro.

Syntax

STOP

LS

This command is used to list the macros which are recorded and available in the memory. The dumped macros will not be listed as they are cleared from the memory as soon as they are dumped in the file.

Syntax

LS

Help

This command provides a list of all the recording commands, with description of their purpose.

Syntax

HELP

To reset command prompt to regular behaviour, you need to mention MODE.

To perform all the above actions or Calculator Pane Commands, Tally must be executed in DevMode.

Actions Used for Key Recording and Playback

Apart from Calculator Pane Commands, there are several TDL Actions provided to programmatically execute the Key Recording operations. They are:

Action – Start Recording

This action is used to start recording every key entered in the memory, with the specified macro name. In the absence of optional parameter Macro Name, default name assumed will be ‘Macro’.

Syntax

Start Recording[ :<Macro Name>]

Where,

<Macro Name> is the name of the macro to be recorded in memory.

Example

[Button: Start Recording]

Title : “Start”

Key : Alt + C

Action : Start Recording : “BS View”

Action – Pause Recording

This action pauses the recording, which can be resumed further. For instance, while recording multiple Vouchers, we might have to run through the Report to check the Number of vouchers, Amount, etc., and then resume recording the Vouchers.

Syntax

Pause Recording

Example

[Button: Pause Recording]

Title : “Pause”

Key : Alt + U

Action : Pause Recording

Action – Resume Recording

This action resumes the paused recording.

Syntax

Resume Recording

Example

[Button : Resume Recording]

Title : “Resume”

Key : Alt + M

Action : Resume Recording

Action – Dump Recording

This action dumps all the recordings to a file with the given separator. Each recording is dumped with its name and keys. This also clears the keys in memory.

Syntax

Dump Recording : <Macro Name> : <Separator between keys>

Where,

<Macro Name> is the name of the macro record e d in memory.

<separator between keys> is the separator to be used between the recording name and keys.

Example:

[Button : Dump Recording]

Title : “Dump”

Key : Alt + G

Action : Dump Recording : “BSView” : “,”

From Release 4.7 onwards, the Action ‘Dump Recording’ has been enhanced to write the macros to a File specified by the user. The Action ‘Dump Recording’ will accept 2 optional parameters, viz. File Name and Separator.

  • If the File Name is left unspecified, then by default, the Action would dump the recording to the file Macros.log.
  • If the Separator is left unspecified, then by default, the system would consider Tilde (~) as the default separator.

Syntax

Dump Recording [: <File Name> [: <Separator between keys>]]

Where,

<File Name> is the name of the file where macro and keys will be recorded.

<Separator between keys> is the separator used to differentiate the macro name from the keys.

Example

[Button : Dump Recording]

Title : “Dump”

Key : Alt + U

Action : Dump Recording : “BSView.txt” : “-”

On clicking the Button ‘Dump Recording’, a file BSView.txt is created in Tally Application Folder.

The behaviour of Calculator Pane Command Dump is retained as in Release 4.6, i.e., it will create a file with the name Macros.Log in the Tally Application Folder.

Action – Stop Recording

This action stops the recording.

Syntax

Stop Recording

Example

[Button : Stop Recording]

Title : ” Stop”

Key : Alt + N

Action : Stop Recording

The recordings once dumped in a file against a name using the above actions, can be replayed by reading the file using File I/O approach and Triggering the keys in a loop using the Action ‘Trigger Key’, which will be covered ahead.

Action – Trigger Key

When the macro keys are recorded using Key Recording Actions or when they are dumped into the Macros File from the Calculator Pane Command; in order to play them back, one needs to make use of the Action Trigger Key, which sends the list of keys in sequence to the system as if an operator is pressing those Keys. The Keystrokes of a required macro can be copied from Macro Log file and pasted against the ‘Trigger Key’ Action, which triggers all those Keys in sequence as required.

Also, Trigger Key accepts a value with Inverted Quotes, which means – trigger this as a value in the current field. For example, V, “Cash”, etc. If the triggered keys enclosed within quotes (“ ”) are executed from a menu, they will be considered as menu keys. For example, “DAS” from Gateway of Tally menu will take the user through Display > Account Books > Sales Register .

Syntax

Trigger Key : <Comma Separated Keys/Values>

Example

Trigger Key : V, F5, Enter, “Cash”, Enter, “Conveyance”, Enter, “50”, Ctrl+A

When the macro keys are recorded using Key Recording Actions or when they are dumped into the Macros File from the Calculator Pane; in order to play them back, one needs to make use of the Action Trigger Key, which sends a list of keys in sequence to the system as if an operator is pressing those Keys.

Very often, some keys like Enter, Up, Down, etc., are repeated in sequence more than once. For example, to scroll down to the 7th Voucher in Daybook, one needs to trigger the Down Key 6 times. Similarly, in an Invoice Entry, moving to the first Item field needs multiple hits of Enter key. Hence, the action ‘Trigger Key’ has now been enhanced to support the <Key>:<Number> combination in the syntax, which will trigger the particular Key for the specified Number of times.

Example: 1

Trigger Key : DD, Enter : 5, “Item 1”, Enter

This is the same as:

Trigger Key : DD, Enter, Enter, Enter, Enter, Enter, “Item 1”, Enter

Following happens when the above Action is invoked from Gateway of Tally:

  • The First D navigates us to Display.
  • The Subsequent D navigates us to Daybook.
  • Enter:5 triggers the Enter Key 5 times, i.e., Drills down into the current voucher, accepts 4 subsequent non-skipped fields, and moves to the 5th non-skipped Field in the Voucher.
  • In the Fifth field, the text Item 1 is entered.
  • The Subsequent Enter then accepts the current field, and the focus is shifted to the next non-skipped field.

Example: 2

Trigger Key : DS, Enter:3

This action will take us through Display (D) -> Statement of Accounts (S) -> Outstandings (1st Enter) -> Receivables (2nd Enter) ; the 3rd Enter selecting the first item in the list and displaying all the outstanding bills within it.

Functions Used for Key Recording

The following function has been introduced for key recording:

Function – $$Recorder Status

This function is used to check the status of the recorder. It returns a String value to indicate whether it is in Started, Stopped or Paused mode.

Syntax

$$RecorderStatus

Post a Comment

Is this information useful?
YesNo
Helpful?