Skip to content

Bug in Windows Forms Apps (.Net 6) #42

@RobinBalean

Description

@RobinBalean

To demonstrate this error, I created a new Windows Forms App with a text box and a button. After pressing the button the text in the text box is sent using InputSimulatorEx after a 5 Second delay like this:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
    private void btn_send_Click(object sender, EventArgs e)
    {
        Thread.Sleep(5000);
        var text = tb_text.Text;
        InputSimulator sim = new();
        sim.Keyboard.TextEntry(text);
    }
}

Start the app and open a notepad.exe Window to display the text. Press the button and make notepad the active window.

Single characters work fine, but if my text is longer , only the first few characters of the text appear. If I start typing in the notepad window the rest of the text shows up. (Sometimes if I wait long enough it appears too.)

The text appears to be stuck inside a buffer, which somehow needs to be nudged to start pushing out letters again.
Is there a way to do this? I tried calling SendKeys.Flush() after the TextEntry, but it didn't help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions