有没有一种办法,而不显示GUI窗口(如控制台应用程序)运行C#应用程序的形式 [英] Is there a way to run c# forms application without showing a gui window (like a console application)

查看:608
本文介绍了有没有一种办法,而不显示GUI窗口(如控制台应用程序)运行C#应用程序的形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种办法,而不显示GUI窗口(如控制台应用程序)运行C#窗体应用程序。我试图把装入 webkit.net控制网页的屏幕短路。

Is there a way to run c# forms application without showing a gui window (like a console application). I'm trying to take screen shorts of webpages loaded into a webkit.net control.

一切正常,我可以得到的截图,但如果有一种方式来运行,而不显示窗口的应用程序,这将是更清洁,包括它在脚本自动化。网页捕获

Everything works fine and I can get screenshots but if there is a way to run the application without showing the window, it will be much cleaner to include it in scripts to automate webpage capture.

我曾尝试:form.hide()方法,但有些怎么不隐藏任何东西。

I have tried: form.hide() method but some how it doesn't hide anything at all.

推荐答案

您的应用程序,当你创建一个新的WinForms应用程序,删除Form1.cs和设计文件中。

Inside your application, when you create a new WinForms application, delete Form1.cs and the designer file.

然后你有下面的代码Program.cs中的主要方法中:

Then inside the Program.cs main method you have the following code:

  Application.EnableVisualStyles();
  Application.SetCompatibleTextRenderingDefault(false);
  Application.Run(new Form1());



删除这些行,并把你所需要的,而不是。确保,如果你想通过添加某种里面循环,以保持程序运行的主要方法从不返回。

Remove these lines, and put what you need instead. Make sure that the Main method never returns if you want to keep the program running by adding some sort of loop inside it.

您也可以考虑创建一个的NotifyIcon 这样你的程序将显示任务栏的通知区域内通知图标。这样,您就可以添加一个菜单来通知图标,使用户有互动,和关闭,应用程序的一些方法。

You can also consider creating a NotifyIcon so that your program will show a notification icon inside the notification area of task bar. This way you can add a menu to the notification icon so the user has some way of interacting, and closing, the application.

这篇关于有没有一种办法,而不显示GUI窗口(如控制台应用程序)运行C#应用程序的形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆