如何使用python脚本控制应用程序 [英] how to control an application using python script

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

问题描述

我有一个使用python脚本调用的cygwin应用程序,如:

os.system(exe文件的路径)

我如何输入cygwin中的文本(已经出现)使用python脚本本身???

I have a cygwin application which i have invoked using python script like:
os.system("path of the exe file")
How can i enter text in the cygwin( which has appeared )using the python script itself???

推荐答案

你是直接从Windows运行Python还是从CygWin运行?如果您从Windows运行Python,您可能需要使用COM将文本发送到CygWin窗口。可以使用win32com模块(包含在PythonWin发行版中)。在这里查看其他帖子以获取更多信息。


我建议您在CygWin上构建Python(或者下载为CygWin构建的Python)然后你可以让任何os.system调用你想要而不是发送文本到CygWin窗口。


最好的问候

/ Fredrik
Are you running Python directly from Windows or from CygWin? In case you run Python from Windows you probably need to use COM to send text to the CygWin window. The win32com module can be used (included in the PythonWin distribution). Look at other posts here for more information.

I would suggest that you build Python on CygWin instead (or download Python built for CygWin) and then you can make any os.system call you want to instead of sending text to the CygWin window.

Best regards
/Fredrik


你能做点什么吗?像这样?
Can you do something like this?
展开 | 选择 | Wrap | 行号


感谢所有您宝贵的建议。

每当我使用popen时调用cygwin应用程序或任何其他应用程序(例如一个简单的记事本)应用程序没有出现在屏幕上


例如。

import os

fd = os.popen(" C:\ cygwin \cygwin.bat"," w")

fd.write(" telnet 101.29.34.132" )

fd.close()


i无法查看此程序所做的任何更改
thanks for all ur valuable suggestions.
Whenever i use popen to invoke cygwin application or any other application(e.g a simple notepad) the application is not appearing on the screen


eg.
import os

fd = os.popen("C:\cygwin\cygwin.bat","w")
fd.write("telnet 101.29.34.132")
fd.close()

i am unable to view any changes this program makes


这篇关于如何使用python脚本控制应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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