Would like to have some insights on how can one wpf application activate another running application and send text messages.
-
You can facilitate ICP (interprocess communication) using WCF. This allows you to use a named pipes or shared memory binding which can be very quick on a local machine. Add to that the fact that you can change the transport layer via configuration means that you can move one of the processes involved in communication to another machine/physical or virtual location and no code changes are required. See here: https://gorillacoding.wordpress.com/2013/02/03/using-wcf-for-inter-process-communication/ – Charleh Feb 01 '18 at 14:07
-
Possible duplicate of [Access existing WPF app instance?](https://stackoverflow.com/questions/1007948/access-existing-wpf-app-instance) – Rekshino Feb 01 '18 at 14:07
1 Answers
Thank you all for the responses.
In fact I was successful in pointing an answer for self. PFB the steps.
- To communicate between two WPF apps without any service connectivity I made use of ClipBoard facility available in Windows
The first WPF app will insert the value which needs to be passed in ClipBoard as below and later will activate the other WPF app who is running in the tray..
Process[] pname = Process.GetProcessesByName("APPNAME"); Clipboard.SetText("TEXT TO BE PASSED");
//Activation
Process[] processes = Process.GetProcessesByName(proc); if (pname.Length != 0) { IntPtr hWnd = processes[0].MainWindowHandle; SetForegroundWindow(hWnd); SetWindowPos(p.MainWindowHandle, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); }
Later in the activated app..through the activated method we could read the value as below
string clipboardText = System.Windows.Clipboard.GetText();
and then clear the clip
System.Windows.Clipboard.Clear();
Hopefully this will help someone. Thanks a lot.