vnc_type_multiline
Type multiple lines of text into a remote system via VNC. Accepts an array of lines to input sequentially, each separated by a newline.
Instructions
Type multiple lines of text, separated by newlines
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lines | Yes | Array of lines to type |
Implementation Reference
- src/tools/input.ts:137-158 (handler)The main handler function for vnc_type_multiline. Iterates over the array of lines, types each line using typeString(), and presses Enter after each line.
export async function handleTypeMultiline( vncManager: VncConnectionManager, args: { lines: string[] } ) { return vncManager.executeWithConnection(async (client) => { // Multi-line mode: type each string as a separate line with Enter after each for (const line of args.lines) { await typeString(client, line); // Always press Enter after each line const enterKeysym = getKeysym('Return'); client.sendKeyEvent(enterKeysym, true); await new Promise(resolve => setTimeout(resolve, 50)); client.sendKeyEvent(enterKeysym, false); await new Promise(resolve => setTimeout(resolve, 100)); // Brief pause between lines } return { content: [{ type: 'text', text: `Typed ${args.lines.length} lines: ${args.lines.join(' | ')}` }] }; }); } - src/server.ts:101-110 (schema)Input schema registration for vnc_type_multiline: takes an array of strings (lines) as input.
{ name: 'vnc_type_multiline', description: 'Type multiple lines of text, separated by newlines', inputSchema: { type: 'object', properties: { lines: { type: 'array', items: { type: 'string' }, description: 'Array of lines to type' } }, required: ['lines'] } - src/server.ts:145-146 (registration)Tool dispatch: case handler that routes 'vnc_type_multiline' to handleTypeMultiline.
case 'vnc_type_multiline': return await handleTypeMultiline(this.vncManager, args as any); - src/tools/input.ts:160-173 (helper)Helper function typeString() that iterates over characters and types them one by one.
async function typeString(client: any, text: string) { // Determine if this text needs slower typing const hasSpecialChars = /[|:;&<>?/\\~`!@#$%^*()+=\[\]{}'",-]/.test(text); const isLongText = text.length > 10; const useSlowTyping = hasSpecialChars || isLongText; // Use different timing based on text complexity const keyHoldTime = useSlowTyping ? 75 : 50; const betweenKeyDelay = useSlowTyping ? 100 : 50; for (const char of text) { await typeCharacter(client, char, keyHoldTime, betweenKeyDelay); } } - src/tools/input.ts:175-210 (helper)Helper function typeCharacter() that handles pressing individual keys including Shift for special characters.
async function typeCharacter( vncClient: VncClient, char: string, keyHoldTime: number, betweenKeyDelay: number ) { // Check if this is a character that needs shift const needsShift = charNeedsShift(char); const keysym = getKeysym(needsShift ? getUnshiftedChar(char) : char); const shiftKeysym = getKeysym('Shift'); console.error(`Typing '${char}' with keysym 0x${keysym.toString(16)}${needsShift ? ' (with Shift)' : ''}`); try { // Press Shift if needed if (needsShift) { vncClient.sendKeyEvent(shiftKeysym, true); await new Promise(resolve => setTimeout(resolve, 10)); } // Press and release the key vncClient.sendKeyEvent(keysym, true); await new Promise(resolve => setTimeout(resolve, keyHoldTime)); vncClient.sendKeyEvent(keysym, false); // Release Shift if it was pressed if (needsShift) { await new Promise(resolve => setTimeout(resolve, 10)); vncClient.sendKeyEvent(shiftKeysym, false); } await new Promise(resolve => setTimeout(resolve, betweenKeyDelay)); } catch (error) { console.error(`VNC library error typing character '${char}':`, error); // Rethrow to fail the entire text operation and allow client retry throw new Error(`VNC buffer error typing character '${char}'. This may be a temporary issue - please retry the operation.`);