我在Windows登录屏幕上运行以下代码,但密码未写入,该怎么办?或如何输入密码

import win32api
#running this code in windows login screen
time.sleep(10)
#password
win32api.keybd_event(55, 0, 0, 0)
win32api.keybd_event(55, 0, 0, 0)
win32api.keybd_event(55, 0, 0, 0)
#password
win32api.keybd_event(13, 0, 0, 0) #enter

最佳答案

首先,应将程序设置为作为服务器运行,因为一旦退出Windows,程序将结束。其次,应在按下每个键后添加KEYEVENTF_KEYUP
win32api.keybd_event(55, 0, KEYEVENTF_KEYUP, 0);

但是,这种自动登录方法不是很酷。您可以使用该工具-Autologon

另一种方法:设置注册表,在键HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon下,设置如下,

"AutoAdminLogon"="1"            //enable Auto Logon
"DefaultUserName"="User"        //set the User Name
"DefaultDomainName"="Domain"    //set the Domain Name
"DefaultPassword"="Password"    //set the Password

关于python - pywin32无法在登录屏幕中使用键盘,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55201563/

10-10 17:41