Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8249925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:42:38+00:00 2026-06-07T23:42:38+00:00

In Visual C#, I’m trying to take text from multiple textboxes (one at a

  • 0

In Visual C#, I’m trying to take text from multiple textboxes (one at a time) and paste them into Notepad. I do this by copying to the clipboard, alt-tabbing, and then pasting into notepad…then again for the other textboxes. This code represents this idea:

subBox1.SelectAll();
subBox1.Copy();
SendKeys.Send("%{TAB}");    // alt+tab
SendKeys.Send("^v");        // paste
SendKeys.Send("{TAB}");     // tab

subBox2.SelectAll();
subBox2.Copy();
SendKeys.Send("^v");
SendKeys.Send("{TAB}");

subBox3.SelectAll();
subBox3.Copy();
SendKeys.Send("^v");
SendKeys.Send("{TAB}");

As you can see, this copies and pastes from three textboxes (named subBox1, 2, and 3). But, for some reason, only the last textbox’s contents are getting copied over. This also happens if I comment out the third box…in that case, only the second textbox’s content gets copied over. I’ve tried using the SelectAll() and Copy() as you see here, as well as the Clipboard class. Both have the same issue.

For example, if the textbox contents are “asdf”, “qwer”, and “zxcv” respectively, all I see is “zxcv” three times.

Any idea why this is happening? I’ve been stuck on this for about an hour now and have no idea what’s going on.

Thanks a ton!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:42:40+00:00Added an answer on June 7, 2026 at 11:42 pm

    SendKeys doesn’t wait for the other application to process the keys you send, so by the time notepad gets around to processing your keypresses, your program has already copied subBox3‘s text over the top of the other texts.

    You need to use SendWait instead.

    As well, instead of sending Alt+Tab, you could use something like this:

    [DllImport("user32.dll", SetLastError = true)]
    static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    
    [DllImport("user32.dll")]
    [return: MarshalAs(UnmanagedType.Bool)]
    static extern bool SetForegroundWindow(IntPtr hWnd);
    
    // ... 
    
    SetForegroundWindow(FindWindow(null, "Untitled - Notepad"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Visual C++, Microsoft Visual Studio 2010 Express: Access from this malloc works: float* block
Visual Studio has a plugin that allows one to copy code from any editor
Visual Studio 2008 insists on indenting HTML like this: <h1> title</h1> <h2> subtitle</h2> where
Visual studio 2005: I am moving from post build event to using the external
Visual Studio 2010 crashes when loading Just trying to start Visual Studio 2010 to
Visual Assist has a feature for colouring methods and functions in VS's text editor.
Visual Studio 2010 C# Is it possible to run and close a program from
Visual Studio keeps trying to indent the code inside namespaces. For example: namespace Foo
Visual Studio compiles the projects into dlls as I want it to, but when
Visual Studio 2008 is great as text editor, but it lacks Python syntax highlighting,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.