我不完全确定这是可能的。
我有一个用C#编写的遗留GUI应用程序。 使用AttachConsole(-1)(来自kernel32.dll)如果从命令行调用它,我可以添加一个控制台窗口。 我甚至能够编写一个模块来运行基本用例,并使其看起来好像是一个控制台应用程序。 我不显示窗口,如果我这样做不更新或正常工作(因为我没有使用Application.Run)
但是,我的团队中的另一个人想要做类似的事情,其中输入参数将引发一系列GUI动作(如buttonExample.PerformClick(),更新文本框等)来模拟用户。 是否有可能完全使用C#或者他必须使用像AutoIt这样的东西?
我们正在使用VS2008 / .NET Framework v3.5。
I'm not entirely sure this is possible.
I have a legacy GUI application written in C#. Using AttachConsole(-1) (from kernel32.dll) I can add a console window if it is called from the command line. I've even been able to write a module to run through basic use cases and make it look as if it is a console application. I don't show the window, and if I do it doesn't update or work properly (because I didn't use Application.Run)
However, another person in my team wants to do something similar where input arguments will set off a series of GUI actions (like buttonExample.PerformClick(), update text boxes, etc) to simulate a user. Is it possible to do this using C# entirely or will he have to use something like AutoIt?
We're using VS2008/.NET Framework v3.5.
最满意答案
您可以将字符串数组args添加到static void Main() ,并将它们传递给GUI类以执行此类操作。
static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { ... //TODO: Stuff with your args } }You can add string array args to your static void Main() and pass them up to the GUI class to perform such actions.
static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { ... //TODO: Stuff with your args } }更多推荐
发布评论