python自动输入账号密码,如何让Python为其打开的.exe文件插入密码和用户名

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

解决方案

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".

好的,这是一个相对简单的Web账号注册界面。我们可以使用HTMLCSS构建界面,然后使用后端语言(如PHP、Python、Node.js等)来处理表单数据的提交存储。 以下是一个基本的HTML模板,您可以在其中添加CSS样式表单元素: ```html <!DOCTYPE html> <html> <head> <title>账号注册</title> <!-- 在这里添加您的CSS样式 --> </head> <body> <div class="container"> <h1>账号注册</h1> <form action="register.php" method="post"> <label for="nickname">昵称:</label> <input type="text" id="nickname" name="nickname" required> <label for="username">用户名:</label> <input type="text" id="username" name="username" required> <label for="password">密码:</label> <input type="password" id="password" name="password" required> <input type="submit" value="注册"> </form> </div> </body> </html> ``` 在这个模板中,我们使用了一个`<form>`元素来创建表单。该表单有三个输入框,用于输入昵称、用户名密码,并且这三个输入框都是必填项(`required`属性)。我们还添加了一个提交按钮,点击它将会提交表单数据到`register.php`页面。 您需要使用后端语言来处理表单数据并将其存储到数据库中。在这个例子中,我们将表单数据提交到`register.php`页面。下面是一个简单的PHP代码示例,它可以接收表单数据并将其存储到MySQL数据库中: ```php <?php // 连接MySQL数据库 $conn = new mysqli("localhost", "username", "password", "mydb"); // 检查连接是否成功 if ($conn->connect_error) { die("连接失败: " . $conn->connect_error); } // 获取表单数据 $nickname = $_POST['nickname']; $username = $_POST['username']; $password = $_POST['password']; // 插入数据到数据库 $sql = "INSERT INTO users (nickname, username, password) VALUES ('$nickname', '$username', '$password')"; if ($conn->query($sql) === TRUE) { echo "注册成功"; } else { echo "注册失败: " . $conn->error; } // 关闭连接 $conn->close(); ?> ``` 请注意,这只是一个简单的示例,您需要根据自己的需求进行修改扩展。例如,您需要添加一些安全性检查,以确保输入的数据是有效安全的。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值