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 116991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:15:56+00:00 2026-05-11T03:15:56+00:00

I wrote a small sample of code in C# to capture selected text from

  • 0

I wrote a small sample of code in C# to capture selected text from other applications:

SendKeys.SendWait('^c'); string searchedText = Convert.ToString(Clipboard.GetText()); 

my problem is its not working if i captured text from the browser Chrome anyone know why this happen or if there is another way to do the same task

UPDATE

I am doing this application to capture selected text from any other application and save it in a file when the user press a hot key.

protected override void WndProc(ref System.Windows.Forms.Message m)     {         // let the base class process the message         base.WndProc(ref m);          // if this is a WM_HOTKEY message, notify the parent object         const int WM_HOTKEY = 0x312;         if (m.Msg == WM_HOTKEY)         {                 SendKeys.SendWait('^c');                 string searchedText = Convert.ToString(Clipboard.GetText());                 Save(searchedText);                 Clipboard.Clear();         }     } 
  • 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. 2026-05-11T03:15:56+00:00Added an answer on May 11, 2026 at 3:15 am

    Well, you are assuming here that Ctrl-C is always going to copy text to the clipboard in every application. That’s a big no-no, you don’t know what will copy text to the clipboard.

    Also, it should be said that using the clipboard for this is a very bad idea if you are not specifically trying to change the contents of the clipboard. It seems you are just using it to copy contents from another application.

    That being said, I recommend that you use the Microsoft UI Automation Library for this. The reference for it is here:

    http://msdn.microsoft.com/en-us/library/ms747327.aspx

    There is also a good article on the subject in MSDN magazine:

    http://msdn.microsoft.com/en-us/magazine/cc163288.aspx

    Specifcally, if you are looking to get selected text, then you want to look at the UI Automation TextPattern Overview located at:

    http://msdn.microsoft.com/en-us/library/ms745158.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Here's a good article that may answer some of your… May 11, 2026 at 11:38 pm
  • Editorial Team
    Editorial Team added an answer Unfortunately you can't because the relationship works the opposite way.… May 11, 2026 at 11:38 pm
  • Editorial Team
    Editorial Team added an answer You want to use the null-coalescing operator, which is designed… May 11, 2026 at 11:38 pm

Related Questions

Where I work we're still on .Net 2.0, but I'm somewhat familiar with the
While writing some C code, I decided to compile it to assembly and read
I'm working to learn Scala--coming from a C++ background. I am trying to write
I can follow most of Apple's WiTap sample, but am sort of stumped on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.