I have simple TCP/IP Server Windows and Client Android. How I can send received text to another appilication for example notepad or excel cell, any window application with input field. Data Received in background
private void Events_DataRecieved(object sender, SimpleTcp.DataReceivedEventArgs e)
{
var ipandPort = e.IpPort;
var data = Encoding.UTF8.GetString(e.Data);
Console.WriteLine(data);
Send(data);
}
I try this
[DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
public void Send(String data)
{
System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName("notepad"); //search for process notepad
if (p.Length > 0) //check if window was found
{
SetForegroundWindow(p[0].MainWindowHandle); //bring notepad to foreground
}
SendKeys.SendWait(data); //send key to notepad
}
How I can send text to any application runnuble on PC after DataRecieved. Like https://barcodetopc.com/ here Thx for help.
As far as I can see you are using the SimpleTcp Nuget package. You can use several 3rd party applications to control the data exchange. Examples of these applications are Hercules or Docklight.
You can create a server in Hercules with your own IP address and the port you specify. Just come to the server tab and say Listen.
In C# application, you can first create a Client.
If you want to listen to messages sent to you
If you want to send a message