C# 向其他应用程序发送文本的按钮';s文本框/聊天室?这种情况下的不和

C# 向其他应用程序发送文本的按钮';s文本框/聊天室?这种情况下的不和,c#,C#,我正在尝试制作一个小程序,当我按下一个按钮时,它会发送一条关于不和谐的信息 我学了一点c#,但我都生锈了,几乎什么都不记得了 希望你能帮忙 这正是我想要的,但我不能让它在不和谐中起作用 [DllImport("user32.dll", EntryPoint = "FindWindow")] private static extern IntPtr FindWindow(string lp1, string lp2); [DllImport("user32.dll", ExactSpelling

我正在尝试制作一个小程序,当我按下一个按钮时,它会发送一条关于不和谐的信息

我学了一点c#,但我都生锈了,几乎什么都不记得了

希望你能帮忙

这正是我想要的,但我不能让它在不和谐中起作用

[DllImport("user32.dll", EntryPoint = "FindWindow")]
private static extern IntPtr FindWindow(string lp1, string lp2);

[DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetForegroundWindow(IntPtr hWnd);

private void button1_Click(object sender, EventArgs e)
{
    IntPtr handle = FindWindow("Notepad", "Untitled - Notepad");
    if (!handle.Equals(IntPtr.Zero))
    {
        if (SetForegroundWindow(handle))
        {
            SendKeys.Send("Hello World!");
            SendKeys.Send("{ENTER}");
        }            
    }
}

按钮是不相关的。您是否询问如何使用C#向Discord服务器发送消息?或者您想以某种方式操纵Discord客户端?我想使用c#向Discord发送消息是的,您可以看看Discord API,特别是