I\'m trying to download file with Python using IE:
from win32com.client import DispatchWithEvents
class EventHandler(object):
def OnDownloadBegin(self):
This is definitely absolutely the last way I would normally do this but today I did have to resort to banging away to get something working. I have IE 10 so @cgohlke's answer won't work (no window text). All attempts to get a proper version of Client Authentication working were failing so had to fall back on this. Maybe it'll help someone else who's equally at the end of their tether.
import IEC
import pywinauto
import win32.com
# Creates a new IE Window
ie = IEC.IEController(window_num=0)
# Register application as an app for pywinauto
shell = win32com.client.Dispatch("WScript.Shell")
pwa_app = pywinauto.application.Application()
w_handle = pywinauto.findwindows.find_windows(title=u'', class_name='IEFrame')[0]
window = pwa_app.window_(handle=w_handle)
window.SetFocus()
# Click on the download link
ie.ClickLink()
# Get the handle of the Open Save Cancel dialog
ctrl = window['2']
# You may need to adjust the coords here to make sure you hit the button you want
ctrl.ClickInput(button='left', coords=(495, 55), double=False, wheel_dist=0)
But man, is it horrible!