可以使用 PHP 来控制 GUI 应用程序吗? [英] Can PHP be used to control a GUI application?

查看:24
本文介绍了可以使用 PHP 来控制 GUI 应用程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个在 Windows 上运行的纯 GUI 应用程序,我想使用 PHP 为其创建一个 Web 界面.甚至有可能吗?我知道我可以使用 system() 或 exec() 之类的函数来启动程序,但是我可以更好地控制正在运行的 GUI 应用程序吗?首先,我希望能够向它发送击键,以便我可以使用它来处理文件、保存输出和退出.

Suppose I have a GUI-only application that runs on Windows and I'd like to create a web interface for it using PHP. Is it even possible? I know I can use functions like system() or exec() to launch programs, but can I have more control over a running GUI app? Primarily, I would like to be able to send it keystrokes, so I can use it to process a file, save the output, and exit.

请指出正确的方向.

推荐答案

你绝对可以做到,但这需要一点技巧.一种方法是编写一个 Windows 命令行应用程序,将按钮点击等发送到 Windows GUI 应用程序.然后,您使用 PHP 和 execsystem 调用调用此命令行应用程序.

You can definitely do it, but it would take a bit of hackery. One way to do it would be to write a Windows command-line app that would send button clicks and such to the Windows GUI app. You then call this command-line app using PHP and the exec and system calls.

例如,如果你传递它说,Firefox,你将有一个 firefox-wrapper 应用程序,可以这样调用:

For example, if you were passing it say, Firefox, you would have a firefox-wrapper app that could be called like this:

firefox-wrapper open-url http://stackoverflow.com
firefox-wrapper press-back
...

这篇关于可以使用 PHP 来控制 GUI 应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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