# -*- coding: utf-8 -*- import codecs import time import traceback import sys import time from datetime import date import datetime import traceback import os import subprocess import ctypes import time import os import pythoncom import win32com import win32com.client from subprocess import Popen import threading import traceback def gen_and_save(AB,itemnum,tabnum,fname): width=1024 height=768 AB.Documents.Item(itemnum).Windows.Item(0).Activate() AB.ActiveDocument.ActiveWindow.SelectedTab=tabnum AW = AB.Documents.Item(itemnum).Windows.Item(0) prefix='c:/gitlab/win10-forex/static' img = prefix+"/"+fname print(AW.ExportImage( img,width,height)) time.sleep(0.2) def runTA(): try: width=1024 height=768 dtnow=datetime.datetime.now() si = subprocess.STARTUPINFO() si.dwFlags |= subprocess.STARTF_USESHOWWINDOW AB = win32com.client.Dispatch("Broker.Application") pythoncom.CoInitialize() AB.Documents.Item(0).Windows.Item(0).Activate() AB.ActiveDocument.ActiveWindow.SelectedTab=0 time.sleep(4) # gen_and_save(AB,0,0,'ec.png') # gen_and_save(AB,2,0,'cad.png') # gen_and_save(AB,2,1,'ydx.png') # gen_and_save(AB,4,0,'day.png') AB.SaveDatabase() pythoncom.CoUninitialize() except Exception: print("exception ") traceback.print_exc() runTA()