简体   繁体   English

如何在 C# 中以编程方式填写另一个程序的弹出字段?

[英]How to to fill out another program's pop up fields programmatically in C#?

I have a C++ program that is launched using cmd.我有一个使用 cmd 启动的 C++ 程序。 After being launched, he show off a pop up where the user has to write his login/password.启动后,他展示了一个弹出窗口,用户必须在其中输入他的登录名/密码。

I want to launch this program with another program (wrote in C#), I know how to do that with System.Diagnostics.Process.Start .我想用另一个程序(用 C# 编写)启动这个程序,我知道如何用System.Diagnostics.Process.Start来做到这一点。

So my question is: ho can I fill the login/password's fields in my C# program ?所以我的问题是:我可以在我的 C# 程序中填写登录名/密码字段吗?

Answer:回答:

@DmitriyZapevalov was right. @DmitriyZapevalov 是对的。 Here is some usefull links that helped me:以下是一些对我有帮助的有用链接:

You have to use Windows API through Interop:您必须通过 Interop 使用 Windows API:

  1. Find popup's window handle ( HWND )查找弹出窗口的窗口句柄 ( HWND )
  2. Find children fields handles查找子字段句柄
  3. Setup your text in fields by handles ( SendMessage(WM_SETTEXT) )通过句柄在字段中设置文本( SendMessage(WM_SETTEXT)

You can find fields and windows by names or IDs.您可以按名称或 ID 查找字段和窗口。

Use Spy++ to investigate popup window layout.使用Spy++调查弹出窗口布局。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM