type_text
Automate text input on Windows systems by typing specified text with optional character delay for controlled automation workflows.
Instructions
输入文本
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | 要输入的文本 | |
| delay | No | 每个字符之间的延迟(毫秒,可选) |
Input Schema (JSON Schema)
{
"properties": {
"delay": {
"description": "每个字符之间的延迟(毫秒,可选)",
"type": "number"
},
"text": {
"description": "要输入的文本",
"type": "string"
}
},
"required": [
"text"
],
"type": "object"
}
Implementation Reference
- src/tools/mouse-keyboard.js:147-164 (handler)Core implementation of the type_text tool handler. Types text using robotjs.typeString, with optional delay between characters implemented via busy-wait loop.typeText(text, delay = 0) { try { if (delay > 0) { for (const char of text) { this.robot.typeString(char); this.robot.keyTap(''); // 简单延迟 const start = Date.now(); while (Date.now() - start < delay) {} } } else { this.robot.typeString(text); } return { success: true, text, message: '文本已输入' }; } catch (error) { return { success: false, error: error.message }; } }
- src/tools/mouse-keyboard.js:50-61 (schema)Input schema definition for type_text tool, specifying required 'text' parameter and optional 'delay'.{ name: 'type_text', description: '输入文本', inputSchema: { type: 'object', properties: { text: { type: 'string', description: '要输入的文本' }, delay: { type: 'number', description: '每个字符之间的延迟(毫秒,可选)' }, }, required: ['text'], }, },
- src/tools/mouse-keyboard.js:112-113 (registration)Registration and dispatch for type_text in the executeTool switch statement, calling the handler with parsed arguments.case 'type_text': return this.typeText(args.text, args.delay);
- src/tools/mouse-keyboard.js:94-95 (registration)type_text is listed among tools that this module can handle in the canHandle method.const tools = ['move_mouse', 'mouse_click', 'type_text', 'press_key', 'get_mouse_position', 'get_screen_size'];