Exemple #1
0
 def init_hwnd(self):
     self.__top_hwnd = findTopWindow(wantedClass='TdxW_MainFrame_Class')
     self.__button = {'refresh': 180, 'position': 145, 'deal': 112, 'withdrawal': 83, 'sell': 50, 'buy': 20}
     windows = dumpWindows(self.__top_hwnd)
     if self.debug: print('windows=',windows)
     temp_hwnd = 0
     temp_hwnd_guanlian=0
     p_hwnd=0
     self.p_acc_hwnd = 0
     self.acc_hwnd = 0
     self.new_stock_order_hwnd = 0
     find_guan_lian = False
     find_new_stock = False
     find_combobox = False
     for window in windows:
         child_hwnd, window_text, window_class = window
         if window_text=='买卖关联同一支股票':
             temp_hwnd_guanlian = child_hwnd
             print("find the hwnd: 买卖关联同一支股票, ",temp_hwnd_guanlian)
         if window_class == 'MHPToolBar' and window_text=='MainViewBar':
             self.p_acc_hwnd = child_hwnd
             print('parent_acc_combobox_hwnd=',self.p_acc_hwnd)
             p_p_acc_hwnd=getParentWindow(self.p_acc_hwnd)
             acc_windows = dumpWindows(self.p_acc_hwnd)   
             for window in acc_windows:
                 child_hwnd, window_text, window_class = window
                 if window_class == 'ComboBox':
                     self.acc_hwnd = child_hwnd
                     find_combobox = True
                     print('acc_combobox_hwnd=',self.acc_hwnd)
         if window_text=='一键申购':
             self.new_stock_order_hwnd = child_hwnd
             find_new_stock = True
         if find_guan_lian and find_new_stock and find_combobox:
             break
     else:
         pass  
         #raise Exception("Change saving type failed") 
                 
     if temp_hwnd_guanlian:
         p_hwnd=getParentWindow(temp_hwnd_guanlian) #买卖关联同一支股票的上一级句柄
         if self.debug: print('p_hwnd=',p_hwnd)
         p_hwnd_children = dumpWindow(p_hwnd)
         if self.debug: print('p_hwnd_children=',p_hwnd_children)
         p_p_hwnd=getParentWindow(p_hwnd) #股票交易第一级句柄
         p_p_hwnd_children = dumpWindow(p_p_hwnd)   #右侧操作区
         self.__menu_hwnds = dumpWindow(p_p_hwnd_children[0][0])
         if self.debug: print(self.__menu_hwnds)
         self.__buy_sell_hwnds = p_hwnd_children
         EXPECT_LEN = 68
         if len(self.__buy_sell_hwnds) != EXPECT_LEN:
             sm.send_mail(sub='无法获得通达信对买对卖界面的窗口句柄',content='子句柄数量为 %s,不等于期望数量:%s.也许软件亿升级。' %(len(self.__buy_sell_hwnds),EXPECT_LEN))
             tkinter.messagebox.showerror('错误', '无法获得通达信对买对卖界面的窗口句柄')
         else:
             pass
     else:
         sm.send_mail(sub='无法获得  买卖关联同一支股票 的窗口句柄',content='请点击  双向委托 按钮' )
         tkinter.messagebox.showerror('错误', '无法获得 "买卖关联同一支股票"的窗口句柄')
     return
Exemple #2
0
    def __init__(self):

        self.__top_hwnd = findTopWindow(wantedText='网上股票交易系统5.0')
        temp_hwnds = dumpWindows(self.__top_hwnd)[0][0]
        temp_hwnds = dumpWindow(temp_hwnds)[4][0]
        self.__buy_sell_hwnds = dumpWindow(temp_hwnds)
        print(len(self.__buy_sell_hwnds) )
        if len(self.__buy_sell_hwnds) != 73:
            tkinter.messagebox.showerror('错误', '无法获得同花顺双向委托界面的窗口句柄')