How can I get Python to plugin my password and Username for an .exe file it opened

心已入冬 提交于 2019-12-12 05:05:41

问题


Hey guys I'm new to programming and I would appreciate some help. My program can open an application I have but to enter the application it requires a password and username which I don't know how to make my program plug in automatically.

os.system('"C:\\abc\\123\\Filepath\\File.exe"')

After the code opens the program of the .exe file how do I make it to where it can than automatically plug in the username and password for the application.

Please and Thank you


回答1:


What you need is Pywinauto, which can make simple windows operations automatically. Please have a look at below Pywinauto website, there is an example to open Notepad and input "Hello World" automatically. https://pywinauto.github.io/

I have another example to use Pywinauto to open putty application and connect to a remote Linux server, then input password to login, and run an Linux command.

from pywinauto.application import Application
import time

app = Application ().Start (cmd_line=u'putty -ssh user_name@10.70.15.175')
putty = app.PuTTY
putty.Wait ('ready')
time.sleep (1)
putty.TypeKeys ("password")
putty.TypeKeys ("{ENTER}")
time.sleep (1)
putty.TypeKeys ("ls")
putty.TypeKeys ("{ENTER}") 

I use Python 2.7 and run the above Python code on Windows successfully.

You may need to install SWAPY (https://github.com/pywinauto/SWAPY) to get the Python code for automating your own "File.exe".



来源:https://stackoverflow.com/questions/39700155/how-can-i-get-python-to-plugin-my-password-and-username-for-an-exe-file-it-open

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!