问题
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()
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
回答1:
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:
- pywin32 / pywinauto not working properly in remote desktop when it is minimized
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.
来源:https://stackoverflow.com/questions/51074956/remote-desktop-connection-using-pywinauto