本文介绍了使用 pywinauto 进行远程桌面连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的脚本能够自动连接到远程桌面.我的问题是我如何能够在登录时将脚本中的文本发送到密码区域的远程桌面连接中.下面是我的脚本

I want that my script will automate to remote desktop connection. My problem is how will i able to send text in a script in loggin in into the remote desktop connection in password area. Below is my script

from pywinauto.application import Application
import win32api
import pywinauto
from pywinauto import keyboard
from pywinauto import timings
import time
from pywinauto.keyboard import SendKeys


app = Application().Start(cmd_line=u'"C:\Windows\system32\mstsc.exe" ')
pywinauto.mouse.move(coords=(1025, 430))
pywinauto.mouse.click(button='left', coords=(1025, 430))
pywinauto.mouse.move(coords=(900, 280))
pywinauto.mouse.click(button='left', coords=(900,280))
time.sleep(1)
keyboard.SendKeys('test123')

#app.WindowsSecurity.Edit.type_keys("pywinauto Works!", with_spaces = True)
#notepad = app[u'Notepad++']
#notepad.Wait('ready')
#menu_item = notepad.MenuItem(u'File->New')
#menu_item.Click()

我的代码在执行远程桌面连接时运行良好.只有密码中的输入文本是我的问题.有人可以帮我解决这个问题吗?非常感谢任何帮助.TIA

My code works well when executed the remote desktop connection will execute. Only the input text in password is my problem. Can someone help me figured this thing out?. Any help is muchly appreciated. TIA

推荐答案

如果你需要在 RDP 窗口中实现 GUI 自动化,你必须在远程机器上安装 pywinauto 并在那里运行脚本.对于任何 GUI 自动化工具都是如此,因为 RDP 或任何其他远程客户端不向本地计算机提供 GUI 元素信息.

If you need GUI automation inside RDP window, you have to install pywinauto on remote machine and run the script there. This is true for any GUI automation tool because RDP or any other remote client doesn't provide GUI elements info to local machine.

此处发布了有关应使用什么的更多详细信息:

More details on what should be used is posted here:

非常有用的线程在这里:https://github.com/pywinauto/pywinauto/issues/401 只需要一些时间将所有这些知识编译成结构良好的文档.

Very useful thread is here: https://github.com/pywinauto/pywinauto/issues/401 Just need some time to compile all this knowledge into well structured document.

这篇关于使用 pywinauto 进行远程桌面连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-19 15:57