将 Java 应用程序变成 Windows 屏幕保护程序
我编写了一个程序,通过深度优先搜索来解决迷宫问题。我想知道如何将这个Java程序变成屏幕保护程序应用程序?有没有办法让 Windows 7 在通常激活屏幕保护程序时启动我的应用程序?
I wrote a program that solves mazes with depth-first search. I was wondering how to turn this Java program into a Screensaver application? Is there a way that Windows 7 starts my app when the screensaver would normally be activated?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
Windows 屏幕保护程序只是接受某些命令行参数的程序。因此,为了让您的程序可以作为屏幕保护程序运行,您必须对其进行编码以接受这些参数。
接下来,您可能希望屏幕保护程序以全屏模式运行。这在 Java 中非常简单,如下例所示:
最后,您需要使用 Launch4j 并为其指定
.scr
扩展名。A Windows screen saver is just program that accepts certain command line arguments. So in order to have your program be runnable as a screen saver you must code it to accept those arguments.
Next you will probably want your screen saver to run in full screen mode. This is very simple to do in Java as the example below shows:
Finally you will need to make your Java program into a Windows executable using something like Launch4j and give it
.scr
extension.我从未使用过这个,但它可能是一个开始的地方。 屏幕保护程序 API。
屏幕保护程序 SDK 的链接目前似乎已损坏,因此我链接到索引页:
I have never used this but it might be the place to start. Screen Saver API.
The link to the screensaver SDK seems to be broken at the moment so I am linking to the index page: JDIC. When they fix their link I'll adjust this.
Windows 屏幕保护程序只是接受某些命令行参数的 exe 文件,详细信息请参见此处。
如果你可以将你的java应用程序编译成exe(我不再使用java了,所以我不确定存在什么工具),然后将其重命名为.scr,就可以了。
或者,只需制作一个 .bat 文件,例如:
.. 并将其重命名为
.scr
。Windows screensavers are just exe files that accept certain command-line arguments, detailed here.
If you can compile your java app into an exe (I don't use java much any more so I'm not sure what tools exist), then rename it to .scr, that would do it.
Or it might be enough just to make a .bat file like:
.. And rename it to
.scr
.我会研究 SaverBeans API,用于在 Java 中创建屏幕保护程序。
I would look into the SaverBeans API for creating screen savers in Java.
使用 JScreenSaver 库。JScreenSaver 是用Java语言为Windows制作屏幕保护程序的中间件
Use the JScreenSaver library.JScreenSaver is the middleware to make a screen saver for Windows in Java language
这种方法的替代方案之一是新的 JavaFX。您可以像在 Swing 中一样创建精美的屏幕保护程序。最重要的是,您可以使用 NetBeans 轻松获得 *.exe 文件。
One of the alternative to this approach is the new JavaFX. You can create fancy screen saver in the same way you do it in Swing. On top of that you get *.exe file quite easily using NetBeans.