使用 C# winforms 与 windows 中的其他桌面应用程序交互

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/912879/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 12:33:35  来源:igfitidea点击:

Interact with other desktop-applications in windows using C# winforms

c#windowswinapidesktop-applicationinteraction

提问by Proximo

I was wondering if its possible to interact with other programs someone with my program. For example clicking a button on another program etc. etc. I'm not sure if this is even possible but if it is could someone provide a little sample code in C#.

我想知道是否可以通过我的程序与其他程序进行交互。例如,单击另一个程序上的按钮等等。我不确定这是否可行,但是否有人可以在 C# 中提供一些示例代码。

Thanks

谢谢

采纳答案by Benji York

You can use UI Automationto interact with other applications.

您可以使用UI 自动化与其他应用程序交互。

回答by Daniel Brückner

You could just create and send messages to the other process. You will have to use P/Invoke for this from C# code.

您可以创建消息并将其发送到另一个进程。为此,您必须从 C# 代码中使用 P/Invoke。

Hereis some code that should point you into the right direction.

这里有一些代码应该指向正确的方向。