type_text
Automates text entry on Windows systems by simulating keyboard input with configurable typing speed for automation workflows.
Instructions
输入文本
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | 要输入的文本 | |
| delay | No | 每个字符之间的延迟(毫秒,可选) |
Implementation Reference
- src/tools/mouse-keyboard.js:147-164 (handler)The handler function for the 'type_text' tool. It types the input text using robotjs.typeString, with optional delay between characters simulated by a busy 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)The input schema and metadata definition for the 'type_text' tool, including name, description, and validation schema.{ 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 in the executeTool switch statement, dispatching 'type_text' calls to the typeText handler.case 'type_text': return this.typeText(args.text, args.delay);
- src/tools/mouse-keyboard.js:93-97 (registration)Registers 'type_text' as a supported tool in the canHandle method for capability checking.canHandle(toolName) { const tools = ['move_mouse', 'mouse_click', 'type_text', 'press_key', 'get_mouse_position', 'get_screen_size']; return tools.includes(toolName); }