TypeKeys Method (ConsoleWindow)

Class

ConsoleWindow.

Action

Sends a set of keystrokes to the console.

Syntax

ConsoleWindow.TypeKeys (sEvents [, nDelay, ensureFocus, sItemIdentifier])
Variable Description
sEvents The keystrokes to type. STRING.
nDelay Optional: The delay between keystrokes (in seconds and fractions of seconds). NUMBER.
ensureFocus

Optional: Whether the agent brings the application to the foreground and then sets the keyboard focus to the control on which the method is executed. This is executed before the first key is typed, which means it is not rechecked for each keystroke when you specify multiple keys to be typed. By default, this variable is set to TRUE. BOOLEAN.

sItemIdentifier The index of the console window or the caption of the window. If this parameter is left blank, Silk4NET sends the keystrokes to the first found console window. STRING.

Notes

  • If no console is open, TypeKeys opens a console.
  • On Windows, TypeKeys first gives the console input focus before typing into it.
  • If you specify nDelay, that value overrides the value set with the OPT_KEYBOARD_DELAY option, which you set with SetOption.
  • If keystrokes are not recognized, you can try to use a higher value for the delay.
  • A key can be followed by a counter, which defines how often the keys should be typed. The counter can be combined with the delay.
  • During the delay time, the screen is locked and interaction with the mouse and keyboard is no longer possible.
  • When recording with the DOM extension TypeKeys ("<Tab>") will not be captured. Since the script refers to object to type in directly, it is not necessary to record this manual Tab. You can manually enter a TypeKeys ("<Tab>") into your script if you want to; it just will not be recorded.
  • When specifying groups of keys, such as Ctrl-Shift, the agent supports plus and minus signs.

Example

The following code sample executes the dir command in the console window to list the files and folders in the directory:

// VB
ConsoleWindow.TypeKeys ("dir<Enter>")
// C#
ConsoleWindow.TypeKeys ("dir<Enter>");