Skip to content

feat: Add write() function for typing text #12

@NakaokaRei

Description

@NakaokaRei

Feature Request: write() Function

Description

Implement write() function to type text strings with optional interval between keystrokes.

Proposed API

public static func write(
    _ text: String,
    interval: TimeInterval = 0
)

Parameters

  • text: The string to type
  • interval: Delay between each keystroke (in seconds)

Example Usage

// Type text instantly
SwiftAutoGUI.write("Hello, World\!")

// Type with 0.1 second delay between characters
SwiftAutoGUI.write("Slowly typed text", interval: 0.1)

// Type in a text field
SwiftAutoGUI.click(x: 100, y: 200)  // Click on text field
SwiftAutoGUI.write("[email protected]")

Implementation Notes

  • Parse string into individual characters
  • Handle special characters and Unicode properly
  • Use existing keyDown()/keyUp() infrastructure
  • Add Thread.sleep for interval between keystrokes

Priority

🟡 Medium - Very useful for form filling and text automation

Related to PyAutoGUI

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions