Esempio n. 1
0
    def TdxLogin(self):
        try:
            self.KillSelf()
            # find = CheckProcessExist('TdxW.exe')

            win32process.CreateProcess(self.path + 'TdxW.exe', '', None, None,
                                       0, win32process.CREATE_NO_WINDOW,
                                       None, self.path,
                                       win32process.STARTUPINFO())  #打开TB,获得其句柄
            time.sleep(3)
            self.handle = win32gui.FindWindow('#32770', '通达信金融终端V7.42')
            #找免费行情
            Tab_handle = win32gui.FindWindowEx(self.handle, None,
                                               'SysTabControl32', 'Tab1')
            p = win32gui.GetWindowRect(Tab_handle)
            Mouse.Click(p[0] + 170, p[1] + 7, 1)

            login = win32gui.FindWindowEx(self.handle, None, 'Button', '登录')
            if login != 0:
                win32gui.PostMessage(
                    win32gui.FindWindowEx(self.handle, None, 'Button', '登录'),
                    win32con.BM_CLICK, 0, 0)
            time.sleep(10)
            EnsureWinowJump = win32gui.FindWindow('#32770', 'TdxW')
            if (EnsureWinowJump != 0):
                Mouse.ClickButton(EnsureWinowJump, '确定')
                time.sleep(10)
            self.CloseInfoTable()

            h = win32gui.FindWindow('TdxW_MainFrame_Class', None)
            win32gui.SetForegroundWindow(h)
            return h

        except Exception as e:
            print(sys._getframe().f_code.co_name + '\t' + str(e))
Esempio n. 2
0
 def Do(self):
     if(self.handle == 0): 
         return
     Mouse.ClickButton(self.handle, '执行选股')
     EnsureWinowJump = win32gui.FindWindow('#32770','TdxW')
     if(EnsureWinowJump != 0):
         Mouse.ClickButton(EnsureWinowJump, '确定')
     time.sleep(3)    
Esempio n. 3
0
    def CountList(self):
        if self.handle == 0:
            self.handle = win32gui.FindWindow('TdxW_MainFrame_Class', self.classname)
        
        x, y = self.GetStockPosByIndex(0)
        Mouse.DoubleClick(x, y, 1)  
        controlInMain.CycleControl(self.x, self.y).ShowOneMinuteCycleDrawing()

        while True:
            h = win32gui.FindWindow('TdxW_MainFrame_Class', None)
            title = win32gui.GetWindowText(h)     
            result = title.replace(']','').split('-')
            if len(result) !=3 :
                break
            name=result[2]
            if self.stockList.count(name) == 0:
                self.stockList.append(name)
            elif self.stockList.count(name) == 1:
                break
            self.Active()
            KeyBoard.key_input_key('page_down')
            time.sleep(0.5)
        
        print(self.stockList)

        KeyBoard.key_input_key('page_down')

        return self.stockList
Esempio n. 4
0
 def ScaleDrawing(self, dir='small', times=3):
     Mouse.Click(1200, 200, 1)
     for i in range(0, times):
         if dir == 'small':
             KeyBoard.key_input_key('down_arrow')
         else:
             KeyBoard.key_input_key('up_arrow')
         i += 1
Esempio n. 5
0
    def CaptureStocksDrawings(self,
                              number=0,
                              stocksWin=stockListWin.StockListWin()):
        imageDict = {}

        if number <= 0:
            return imageDict

        left, top = stocksWin.GetWindowPos()
        tc = controlInMain.CycleControl(left, top)

        for index in range(0, number):
            x, y = stocksWin.GetStockPosByIndex(index)
            if (index == 0):
                Mouse.DoubleClick(x, y, 1)
                tc.ShowMultiCycle()
            else:
                center = [int(self.pos[2] / 3), int(self.pos[3] / 3)]
                Mouse.ClickPos(center)
                KeyBoard.key_input_key('page_down', 2)

            h = win32gui.FindWindow('TdxW_MainFrame_Class', None)
            title = win32gui.GetWindowText(h)
            result = title.replace(']', '').split('-')
            if len(result) != 3:
                name = '未知名字'
            name = result[2]

            imageName = self.imagePath + "%d.jpg" % (index)
            capture.WindowCapture(imageName)
            imageDict[name] = imageName
            index += 1
            msg = '%s %s' % (time.strftime("%H:%M:%S"), name)
            webchat.send(msg, imageName)

        tc.QuitMultiCycle()
        return imageDict
Esempio n. 6
0
    def UpdataRealTimeData(self, dataType=1):
        try:
            self.Open()

            if dataType & int('0x1', 16):
                Mouse.ClickPos(self.GetControlPostion(u'沪深分钟线'))
                Mouse.ClickPos(self.GetControlPostion(u'1分钟线数据'))
            
            if dataType & int('0x2', 16):
                Mouse.ClickPos(self.GetControlPostion(u'沪深分钟线'))
                Mouse.ClickPos(self.GetControlPostion(u'5分钟线数据'))

            if dataType & int('0x4', 16):
                Mouse.ClickPos(self.GetControlPostion(u'日线数据'))
                Mouse.ClickPos(self.GetControlPostion(u'日线和实时行情数据'))

            Mouse.ClickButton(self.handle, u'开始下载')
            
            if self.IsOver(): 
                self.Close()
        
        except Exception as e:
            print(sys._getframe().f_code.co_name+'\t'+str(e))
Esempio n. 7
0
 def ShowMultiCycle(self):
     Mouse.ClickPos(self.GetOneMinutePos())
     Mouse.ClickPos(self.GetMutiTimePos())
     self.ScaleDrawing()
     time.sleep(3)
Esempio n. 8
0
 def ShowOneMinuteCycleDrawing(self):
     Mouse.ClickPos(self.GetOneMinutePos(), 1)
Esempio n. 9
0
 def SyncSelfChoose(self):
     windowMenu.Menus(self.pos[0],
                      self.pos[1]).OpenWindowByMenu(u'同步', u'上传自选股')
     time.sleep(1)
     h = win32gui.FindWindow('#32770', u'执行进度')
     Mouse.ClickButton(h, u'完成')
Esempio n. 10
0
 def SwitchToSelfChooseMainFrame(self):
     Mouse.ClickPos(
         controlInMain.SelfChoose(self.pos[0],
                                  self.pos[1]).GetSelfChooseButtonPos())
Esempio n. 11
0
 def OpenWindowByMenu(self, menu=u'系统', subMenu=u'盘后数据下载'):
     Mouse.ClickPos(self.GetMenuPostion(menu), 0.5)
     Mouse.ClickPos(self.GetMenuPostion(subMenu), 0.5)
Esempio n. 12
0
 def AddAllToSelfChoose(self):
     time.sleep(1)
     Mouse.ClickButton(self.handle, u'全选中')
     Mouse.ClickButton(self.handle, u'加入到板块')
     AddToSelfChoose().OK()
Esempio n. 13
0
 def OK(self):
     time.sleep(1)
     Mouse.ClickButton(self.handle, u'确定')
Esempio n. 14
0
 def ImportCase(self, index):
     if self.handle == 0:
         return
     Mouse.ClickButton(self.handle, '引入方案', 2)
     SelectStockCaseFileWindow().SelectCaseByIndex(index)
     time.sleep(1)
Esempio n. 15
0
 def SelectCaseByIndex(self, index):
     x, y = self.GetCasePostionByIndex(index)
     Mouse.DoubleClick(x, y, 1)