I'm looking for an example code written in C# how do I the communication of my application with another application using. I have an another application that have an ComboBox. I want set the value of this Combobox from my application, using C# code.
-
Have you done any research? WCF comes to mind.– M.BabcockFeb 3, 2012 at 2:12
-
@Jack, please check if my edit/re-tagging matches what you asking. Note that it may be good idea to state your overall goal as there are much better ways of communicating between processes.– Alexei LevenkovFeb 3, 2012 at 2:15
-
Can you explain more, what this has to do with ui automation?– Andrew SavinykhFeb 3, 2012 at 2:17
-
@zespri, This is how I read - "I want set the value of this Combobox from my application", could be totally off. Should not have put it in it I guess - removing till Jack is back...– Alexei LevenkovFeb 3, 2012 at 2:20
-
Google "hooking in C#", which is what you need.– HolystreamFeb 3, 2012 at 2:23
4 Answers
you can use a number of technologies.... none are super simple.
- Sockets
- MSMQ
- Named Pipes
- WCF ( which wraps the three above, and other techniques, can be a bit fiddly to get working)
- DCOM
- Windows "SendMessage"
- Files
- Shared Memory
-
1
You need to learn and use Windows Communication Foundation. Have a look at MSDN article - What Is Windows Communication Foundation?
In your case, there are two ways:
- RPC, the preferred way. the 'other' app should expose RPC API, you the app can invoke and communicate with the 'other' app;
- UI Automation, the bad way. You can use Windows API to get a handle of the ComboBox in the 'other' app, and send key stroke event to stimulate human interaction. But it is not reliable. E.g. you cannot lock your screen when the app is running, or you cannot stimulate the action.
-
You can access Win32 API to Block Input which disables keyboard and mouse input to prevent user interaction Feb 3, 2012 at 2:26
Some code samples can be found here: http://1code.codeplex.com/wikipage?title=IRPC