Automating WinSCP file transfer in Python using using pywinauto


I am trying to automate a file transfer process in WinSCP using Python and pywinauto. I am currently sending keyboard keys of Ctrl+ to open a directory and search a path, but when I run my program, it will not open the open directory window. Please help!


app1 = Application().connect(title=u'Open directory')
win1 = app1.TOpenDirectoryDialog

src_folder = "/data/cog/deployments"

This is the error code I am getting:

Traceback (most recent call last):
  File "", line 49, in <module>
    app1 = Application().connect(title=u'Open directory')
  File "", line 997, in connect
    self.process = findwindows.find_element(**kwargs).process_id
  File "", line 87, in find_element
    raise ElementNotFoundError(kwargs)
pywinauto.findwindows.ElementNotFoundError: {'title': 'Open directory', 'backend': 'win32', 'visible_only': False}
Asked By: Rae



Do not try to implement file transfer by automating WinSCP GUI!

Use WinSCP scripting. Start at:

WinSCP GUI can even generate script template for you:

Or use native Python file transfer libraries. ftplib for FTP. Or Paramiko for SFTP.

Answered By: Martin Prikryl
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.