简体   繁体   中英

Getting textbox value from a 3rd party app in C#

I am trying to develop a background working C# application, that needs to detect when a random 3rd party application is opened, filled out and a button is clicked.

I know i can get some info for the 3rd party app as a process, but is it possible to iterate through all of it's controls and get their values?

I've read something about "anonymous pipes" but don't know if those could be implemented in a case like this one, and how.

My final goal is to get the value of one specific textbox in the app, when a "Print" button is clicked in that same app. The third party app was not developed by me, so i only have it as an .exe but i can see that it has textboxes, labels and buttons.

What you need is inter-process communication There are multiple approaches to solve your problem :

1. Using common data store

On click of print button you can set some flag and the textbox text in the database / file. the other application can poll to check if this flag is set.

Once this is set, the other application can read this from database / file.

2. You can have a Net Pipe Binding WCF endpoint hosted from the other application.

I would prefer this option if I have to send data from one process to other process on same machine.
Your main appplication will have proxy of wcf service. Wcf service will be part of other application which needs to know textbox text.

On click of "Print" button, your main application will send text box text to this WCF service.

Because this is using Named Pipe binding, this service would be available only from that machine.

Refer example from this blog .

There can be other ways too (eg hosting web api which allows access from localhost only). The choice of approach depends on high level design of your programs.

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM