-1

I am new to C# and Windows development.

A specific, closed-source, third-party application running in Windows periodically produces text. I would like to access this text programatically. The text produced is copyable/pasteable, i.e. I can highlight it, Ctrl-C and paste it into Notepad. I looked into tackling this with OCR but it seems like overkill -- is there an easier way in C#?

dgvid
  • 26,293
  • 5
  • 40
  • 57
bpnolan
  • 28
  • 4
  • There are easier ways, but (sadly) none that are 100% reliable (i.e., that don't fail on focus change, etc.) See [this question](http://stackoverflow.com/questions/4243944/how-to-get-selected-text-from-any-window-using-ui-automation-c-sharp/17604029#17604029) – Eric Brown May 20 '14 at 23:34

2 Answers2

0

if you just want to automate a simple job then mackgyver it simply by combining well placed mouse clicks MouseEventArgs(System.Windows.Forms.MouseButtons.Left, 1, 1, 1, 1)) and key events like SendKeys.Send("^c") and SendKeys.Send("^v") ;)

Should do the trick but not elegant at all!

RoDoTiQ
  • 61
  • 4
0

Like RoDoTiQ said, you can just send the SendKeys function to copy the data from the application to your clipboard. The problem being with that is that if you wanted to do it automatically you would need the application to focus on that Window for you first.

If you were thinking about doing it also it might be easier to just send the Ctrl + a combination to select all the text and parse out the data you don't want. Alternatively you can take a look at this Stackoverflow article that outlines what you want to do:

Capturing data from a window in a closed-source third-party Win32 application

I haven't tried it for myself though, so I can't promise it will work. Good luck!

Community
  • 1
  • 1
Frank
  • 75
  • 2
  • 13