根据输入参数控制C#GUI(Controlling a C# GUI based on input arguments)

编程入门 行业动态 更新时间:2024-10-13 22:20:38
根据输入参数控制C#GUI(Controlling a C# GUI based on input arguments)

我不完全确定这是可能的。

我有一个用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 } }

更多推荐

本文发布于:2023-08-02 04:37:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1368742.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:参数   GUI   Controlling   arguments   input

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!