|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Internet and Network > MCP. - MCP (Model-Context Protocol) server operations > Status & Configuration - Server status and features > MCP Commands - Input Simulation |
MiniRobot Language (MRL) - MCP Input Simulation Commands
MCP.WriteKB
Write Text to Keyboard Buffer
Purpose
The MCP.WriteKB command simulates keyboard input by writing text to the system keyboard buffer. This allows scripts to send keystrokes to the active window or a specified target window.
This command is useful for:
• Automating data entry in other applications
• Sending keyboard shortcuts and commands
• Testing applications with simulated input
• Controlling other programs via keyboard interface
Syntax
MCP.WriteKB|$$TEXT
MCP.WriteKB|$$TEXT|$$WINDOW
Parameters
$$TEXT - The text to write to the keyboard buffer. Special keys can be represented using codes like {ENTER}, {TAB}, {ESC}, {F1}-{F12}, etc.
$$WINDOW - (Optional) The target window title or handle. If omitted, the text is sent to the currently active window.
Special Key Codes
{ENTER} or {RETURN} - Enter/Return key
{TAB} - Tab key
{ESC} - Escape key
{SPACE} - Space key
{BACKSPACE} - Backspace key
{F1} to {F12} - Function keys
{CTRL+x} - Ctrl+key combination
{ALT+x} - Alt+key combination
{SHIFT+x} - Shift+key combination
Return Value
Returns a status code indicating the result:
OK - Text was sent successfully
NOTFOUND - Target window not found
ERROR - Failed to send keyboard input
Examples
' Example 1: Type text to active window
MCP.WriteKB|Hello, World!
' Example 2: Send keyboard shortcut
MCP.WriteKB|{CTRL+s}
' Example 3: Fill a form
MCP.WriteKB|John Doe{TAB}25{TAB}New York{ENTER}
' Example 4: Send to specific window
MCP.WriteKB|Search query{ENTER}|Notepad
Remarks
The command sends keystrokes to the target window as if they were typed by a user. The target window should have input focus for the keystrokes to be processed correctly.
When sending to a specific window, the command will first attempt to activate that window. If the window cannot be found or activated, a NOTFOUND error is returned.
Note that some applications may have security features that block simulated keyboard input. In such cases, the command may return OK but the input may not be processed by the target application.
Error Conditions
The command will fail with an error if:
• The text parameter is missing
• The specified window cannot be found
• Keyboard input simulation fails
• Too many parameters are provided
See also:
• MCP.Screenshot - Capture Screen