def Tijiao(): Position_frame = get_val('Position_frame') Click(Position_frame[2][0], Position_frame[2][1]) set_val('tijiao_OK', False) # 需要按E解锁,自动提交 set_val('chujia_on', True) # 激活自动 smart_autoprice = get_val('smart_autoprice') tijiao_num = get_val('tijiao_num') # print("tijiao_num", tijiao_num) # print("smart_autoprice", smart_autoprice) if tijiao_num == 2: set_val('current_pricestatus_label', '等待第三次出价') second_time1 = get_val('second_time1') second_diff = get_val('second_diff') current_pricestatus = '{0:.1f}秒加{1}'.format(second_time1, second_diff) set_val('current_pricestatus', current_pricestatus) elif tijiao_num == 0: set_val('current_pricestatus_label', '等待拍牌结果') set_val('current_pricestatus', '请不要关闭页面') elif tijiao_num == 3: print("tijiao_fsdfs") set_val('current_pricestatus_label', '智能补枪') set_val('current_pricestatus', '智能出价') print("开启智能出价") set_val('smartprice_chujia', True) ##开启智能出价, 打开确认查找 wx.CallAfter(pub.sendMessage, 'update info', action=f'触发自动补枪')
def __init__(self, parent): infopanel_size = get_val('infopanel_size') infopanel_pos = get_val('infopanel_pos') super(InfoPanel, self).__init__(parent, size=infopanel_size, pos=infopanel_pos) super(InfoPanel, self).SetScrollbars(0, 20, 0, 5) self.SetScrollRate(0, 20) self.infomationfont = wx.Font(14, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False) self.infofont = wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False) self.areafont = wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False) self.init_info() self.hbox = wx.BoxSizer(wx.HORIZONTAL) self.SetBackgroundColour('white') # self.Bind(wx.EVT_PAINT, self.on_paint) self.Bind(wx.EVT_SCROLLWIN_TOP, self.up) self.Bind(wx.EVT_SCROLLWIN_BOTTOM, self.down) self.Bind(wx.EVT_SCROLLWIN_LINEUP, self.refreshtext) self.Bind(wx.EVT_SCROLLWIN_LINEDOWN, self.refreshtext) self.Bind(wx.EVT_SCROLLWIN_PAGEUP, self.pageup) self.Bind(wx.EVT_SCROLLWIN_PAGEDOWN, self.pagedown) self.Bind(wx.EVT_SCROLLWIN_THUMBRELEASE, self.refreshtext) self.Bind(wx.EVT_SCROLLWIN_THUMBTRACK, self.refreshtext) self.Bind(wx.EVT_PAINT, self.refreshtext) # self.ShowScrollbars(wx.SHOW_SB_NEVER, wx.SHOW_SB_NEVER) # self.EnableScrolling(False, False) # 更新日志 pub.subscribe(self.update_info, 'update info')
def find_yan_confirm(): try: dick_target = get_val('dick_target') template = dick_target[1] imgpos_yanzhengmaconfirm = get_val('imgpos_yanzhengmaconfirm') sc = imgpos_yanzhengmaconfirm img = cv2.cvtColor(sc, cv2.COLOR_BGR2GRAY) # 转灰度图 w, h = template.shape[::-1] res = cv2.matchTemplate(img, template, cv2.TM_CCOEFF_NORMED) min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res) yanzhengma_control = get_val('yanzhengma_control') if max_val > 0.9 and yanzhengma_control: set_val('yanzhengma_view', True) # smartprice_chujia = get_val('smartprice_chujia') # if smartprice_chujia: # set_val('smartprice_tijiao', True) ##这代表出价成功 elif max_val <= 0.9: set_val('yanzhengma_view', False) set_val('yanzhengma_close', True) set_val('yanzhengma_control', True) smartprice_tijiao = get_val('smartprice_tijiao') # if smartprice_tijiao: # set_val('smartprice_tijiao', False) ##这代表出价成功 # set_val('smartprice_chujia', False) except: logger.exception("error message")
def read_lowest_price(self): lowest_price = get_val('lowest_price') lowestpricelist = get_val('lowestpricelist') a_time = get_val('a_time') try: str_price = Price_read() if len(str_price) == 5: ##防止前面 price = int(str_price) # 获取当前最低价 # print('price=', price) if price in lowestpricelist: # 字典查找 set_val('findpos_on', False) if lowest_price == price: trans_time() # 保存价格 else: set_val('lowest_price', price) trans_time() # 保存价格 set_val('changetime', a_time) else: set_val('findpos_on', True) else: set_val('findpos_on', True) except: # print("识别价格失败") set_val('findpos_on', True) logger.error("识别价格失败") logger.exception('this is an exception message')
def cut_img( ): # 将所得的img 处理成 lowestprice_img confirm_img yanzhengma_confirm_img refresh_img use_area = get_val('use_area') sc_area = get_val('sc_area') img = only_screenshot(sc_area) # 获取得到的截图 img = np.asarray(img) # 转化为numpy数组 try: set_val('imgpos_lowestprice', img[use_area[0][1]:use_area[0][3], use_area[0][0]:use_area[0][2]]) # ok set_val('imgpos_refresh', img[use_area[1][1]:use_area[1][3], use_area[1][0]:use_area[1][2]]) # ok set_val( 'imgpos_confirm', img[use_area[2][1]:use_area[2][3], use_area[2][0]:use_area[2][2]]) set_val('imgpos_yanzhengma', img[use_area[3][1]:use_area[3][3], use_area[3][0]:use_area[3][2]]) # ok set_val('imgpos_yanzhengmaconfirm', img[use_area[4][1]:use_area[4][3], use_area[4][0]:use_area[4][2]]) # ok set_val( 'imgpos_currenttime', img[use_area[5][1]:use_area[5][3], use_area[5][0]:use_area[5][2]]) set_val( 'imgpos_question', img[use_area[6][1]:use_area[6][3], use_area[6][0]:use_area[6][2]]) set_val( 'imgpos_result', img[use_area[7][1]:use_area[7][3], use_area[7][0]:use_area[7][2]]) except: logger.error("cut_img 这里出错") logger.exception('this is an exception message')
def findconfirm(): dick_target = get_val('dick_target') smartprice_chujia = get_val('smartprice_chujia') template = dick_target[1] imgpos_confirm = get_val('imgpos_confirm') sc = imgpos_confirm img = cv2.cvtColor(sc, cv2.COLOR_BGR2GRAY) # 转灰度图 w, h = template.shape[::-1] res = cv2.matchTemplate(img, template, cv2.TM_CCOEFF_NORMED) min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res) if max_val >= 0.7: # print(max_val, smartprice_chujia) if not smartprice_chujia: OnClick_confirm() #点击确认 else: print("找到确认") Smart_chujia() ##结果查找 need_findresult = get_val('need_findresult') if need_findresult: print("查找结果") get_result() ##确认结果 #再判定是否需要点击确认 else: set_val('need_findresult', True)
def Second_tijiao_time_smart1(self, event): one_time2_smart1 = get_val('one_time2_smart1') one_time2_smart2 = get_val('one_time2_smart2') tem = self.second_tijiao_time_smart1.GetValue() timelist = get_val('timelist') strategy_type = get_dick('strategy_type') one_time1 = get_val('one_time1') second_time1 = get_val('second_time1') if strategy_type == '2': if int( tem * 10 ) in timelist and tem <= one_time2_smart2 - 1 and tem >= one_time1 + 1: print(one_time2_smart2, tem) one_time2_smart1 = tem set_val('one_time2_smart1', float(tem)) set_val('one_realtime2_smart1', gettime(one_time2_smart1)) # 计算得到的时间戳 self.update_strategy() else: self.second_tijiao_time_smart1.SetValue(one_time2_smart1) elif strategy_type == '3': if int( tem * 10 ) in timelist and tem <= one_time2_smart2 - 1 and tem >= second_time1 + 1: one_time2_smart1 = tem set_val('one_time2_smart1', float(tem)) set_val('one_realtime2_smart1', gettime(one_time2_smart1)) # 计算得到的时间戳 self.update_strategy() else: self.second_tijiao_time_smart1.SetValue(one_time2_smart1)
def cut_pic(size, name): imgpos_yanzhengma = get_val('imgpos_yanzhengma') imgpos_question = get_val('imgpos_question') imgpos_yanzhengma = np.asarray(imgpos_yanzhengma) imgpos_question = np.asarray(imgpos_question) ##对空白裁剪 # shape (110, 210, 3) #(70, 210, 3) #(24, 251, 3) # (54, 180, 3) # (24, 253, 3) # (430, 220) i1 = imgpos_yanzhengma[:, :] i2 = imgpos_question[:, :] # i2 = cv2.resize(i2, (180, 62)) # i1 = cv2.resize(i1, (360, 108), interpolation=cv2.INTER_LANCZOS4) # i2 = cv2.resize(i2, (360, 34), interpolation=cv2.INTER_LANCZOS4) # set_val('Pos_yanzhengma_relative', (-247, - 12, - 67, + 43)) # 验证码所在位置 # set_val('Pos_question_relative', (-280, - 65, - 23, -41)) ##问题所在位置 #(55, 180, 3) # (24, 257, 3) i1 = cv2.resize(i1, (430, 131), interpolation=cv2.INTER_AREA) i2 = cv2.resize(i2, (430, 40), interpolation=cv2.INTER_AREA) im = np.concatenate([i2, i1]) # im = cv2.resize(im, tuple(size))0 cv2.imwrite(name, im)
def refreshtext(self, event): xx = self.GetViewStart() LABEL_NUM = get_val('LABEL_NUM') pos = xx[1] print(pos) if pos <= 30: x, y = get_val('infotext_pos') dc = wx.BufferedDC( wx.ClientDC(self)) # ClientDC客户区 ,BufferedDC双缓冲绘图设备 dc.SetBackground(wx.Brush(self.GetBackgroundColour())) dc.Clear() self.draw_infomation(dc) print(self.infos) print(len(self.infos)) len_info = len(self.infos) len_info = len_info if len_info <= LABEL_NUM else LABEL_NUM for i in range(len_info): self.draw(dc, self.infos[i], (x, y + 20 * i)) else: x, y = get_val('infotext_pos') dc = wx.BufferedDC( wx.ClientDC(self)) # ClientDC客户区 ,BufferedDC双缓冲绘图设备 dc.SetBackground(wx.Brush(self.GetBackgroundColour())) dc.Clear() self.draw_infomation(dc) index = (pos - 23) // 7 if len(self.infos) <= index + LABEL_NUM: index = len(self.infos) - LABEL_NUM for i in range(8): print(f'index={index}') self.draw(dc, self.infos[index + i], (x, y + 20 * i)) event.Skip()
def Modify(self): # 更新 dc = wx.BufferedDC( wx.ClientDC(self)) # ClientDC客户区 ,BufferedDC双缓冲绘图设备 w, h = self.GetClientSize() dc.SetBackground(wx.Brush(self.GetBackgroundColour())) ##保存刷新不闪烁 dc.Clear() register_label = get_val("register_label") dc.SetFont(self.textfont) tw, th = dc.GetTextExtent(register_label) dc.DrawText(register_label, 35, (h) / 2 - th / 2) ##更改激活状态 activate_status = get_val('activate_status') if activate_status: dc.DrawBitmap(self.registered_bitmap, 2, 0, True) else: dc.DrawBitmap(self.unregistered_bitmap, 2, 0, True) netspeed_label = get_val("netspeed_label") dc.SetFont(self.textfont) tw, th = dc.GetTextExtent(netspeed_label) dc.DrawText(netspeed_label, 806, (h) / 2 - th / 2) dc.DrawBitmap(self.quick_bitmap, 850, -3, True) strategy_label = get_val('strategy_label') strategy_name = get_val('strategy_name') strategy_description = get_dick('strategy_description') text = "{0} {1} {2}".format(strategy_label, strategy_name, strategy_description) dc.SetFont(self.textfont) tw, th = dc.GetTextExtent(text) dc.DrawText(text, 270, (h) / 2 - th / 2)
def Onekey_login(): guopai_on = get_val('guopai_on') if guopai_on: wx.CallAfter(pub.sendMessage, "onekey_login") ##截图 Pos_login = get_val('Pos_login') wx.CallAfter(pub.sendMessage, 'update info', action='一键登录')
def Save(self, event): bid_number = self.accountText.GetValue() bid_password = self.passwordText.GetValue() idcard = self.idnumberText.GetValue() set_val('bid_number', bid_number) set_val('bid_password', bid_password) set_val('idcard', idcard) print(bid_number, bid_password, idcard) bidnumber_js = "document.getElementById('bidnumber').value = '{0}';".format( bid_number) bidpassword_js = "document.getElementById('bidpassword').value = '{0}';".format( bid_password) idcard_js = "document.getElementById('idcard').value = '{0}';".format( idcard) set_val('bidnumber_js', bidnumber_js) set_val('bidpassword_js', bidpassword_js) set_val('idcard_js', idcard_js) ##同步到strategy_data manage = get_val('manage') if manage: strategy_data = get_val('strategy_data') identify = get_val('identify') strategy_data[identify]['Bid_number'] = bid_number strategy_data[identify]['Bid_password'] = bid_password strategy_data[identify]['ID_number'] = idcard set_val('strategy_data', strategy_data) self.Destroy()
def OnClick_Tijiao(delay=0): one_delay = get_val('one_delay') second_delay = get_val('second_delay') tijiao_num = get_val('tijiao_num') twice = get_val('twice') smart_autoprice = get_val('smart_autoprice') set_val('confirm_need', True) print("tijiao_num", tijiao_num) print("smart_autoprice", smart_autoprice) print("twice", twice) if tijiao_num == 1: if twice: set_val('tijiao_num', 2) elif smart_autoprice: set_val('tijiao_num', 3) else: set_val('tijiao_num', 0) timer = threading.Timer(delay, Tijiao) timer.start() set_val('tijiao_on', False) elif tijiao_num == 2: set_val('tijiao_num', 0) timer = threading.Timer(delay, Tijiao) timer.start() set_val('tijiao_on', False) elif tijiao_num == 3: set_val('tijiao_num', 0) Tijiao() else: Tijiao()
def __init__(self): Timesize = get_val('Timesize') Pos_timeframe = get_val('Pos_timeframe') wx.Frame.__init__(self, None, title="wx.Timer", size=Timesize, pos=Pos_timeframe, style=wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP) # wx.Frame.__init__(self, None, -1,'Time',size=(400,160), pos=Pos_timeframe, # style=wx.FRAME_TOOL_WINDOW|wx.STAY_ON_TOP) ClockWindow(self, Timesize)
def changewebsize(self, event): x, y = self.parent.GetSize() if x > 950: smallwebsize = get_val('smallwebsize') self.parent.SetSize(smallwebsize) else: websize = get_val('websize') self.parent.SetSize(websize)
def trans_time(): pricelist = get_val('price_list') lowest_price = get_val('lowest_price') a_time = get_val('a_time') structtime = time.localtime(a_time) timestr = time.strftime("%H-%M-%S", structtime) hour, minute, second = timestr.split('-') if int(hour) == 11 and int(minute) == 29: pricelist[int(second)] = lowest_price
def close_yanzhengma(self): Position_frame = get_val('Position_frame') auto_yanzhengma_on = get_val('auto_yanzhengma_on') print(auto_yanzhengma_on) # if auto_yanzhengma_on: Click(Position_frame[7][0], Position_frame[7][1]) print("fsdfsdsfs") self.tipframe.Show(False) set_val('auto_yanzhengma_on', False) ##设置成查看状态
def create_info(action): true_time_str = get_val('true_time_str') if not true_time_str: true_time = get_val('true_time') time_local = time.localtime(true_time) true_time_str = time.strftime("%H:%M:%S", time_local) # + '.' + str(b_time) info = f'[{true_time_str}]:{action}' return info
def Second_tijiaoyanchi_time_smart3(self, event): one_delay_smart3 = get_val('one_delay_smart3') tem = self.second_tijiaoyanchi_time_smart3.GetValue() yanchilist = get_val('yanchilist') if int(tem * 10) in yanchilist: set_val('one_delay_smart3', float(tem)) self.update_strategy() else: self.second_tijiaoyanchi_time_smart3.SetValue(one_delay_smart3)
def init_account(self): bid_number = get_val('bid_number') bid_password = get_val('bid_password') idcard = get_val('idcard') if bid_number and bid_number != 'null' \ and bid_password and bid_password != 'null' \ and idcard and idcard != 'null': self.accountText.SetValue(bid_number) self.passwordText.SetValue(bid_password) self.idnumberText.SetValue(idcard)
def smart_price(): lowest_price = get_val('lowest_price') a_time = get_val('a_time') structtime = time.localtime(a_time) timestr = time.strftime("%H-%M-%S", structtime) hour, minute, second = timestr.split('-') if int(hour) == 11 and int(minute) == 29: add_price = time_price.get(second, 1300) return add_price + lowest_price else: return 1300 + lowest_price ##除了榜上有的其余均加1300出价
def move(self, event): self.Destroy() moni_on = get_val('moni_on') moni_webframe = get_val('moni_webframe') guopai_webframe = get_val('guopai_webframe') if moni_on: moni = wx.FindWindowById(moni_webframe) moni.SetFocus() else: guopai = wx.FindWindowById(guopai_webframe) guopai.SetFocus()
def init_info(self): action_infos = get_val('action_infos') len_info = len(action_infos) print("fdsfsfdsfds") if len_info > 5: self.infos = [action for action in action_infos[-6:]] self.update_info() else: new_actions = get_val('new_actions') self.infos = [self.create_info(action) for action in new_actions] self.update_info() set_val('action_infos', copy.deepcopy(self.infos))
def Cancel_chujia_test(): x, y = win32api.GetCursorPos() print(x, y) # 615 546 # 689 559 from component.read_pic import grab_screen2 imgpos_yanzhengmaconfirm = get_val('imgpos_yanzhengmaconfirm') # img = grab_screen2(region=(x, y, x + 76, y + 16)) cv2.imwrite('yan_confirm.png', imgpos_yanzhengmaconfirm) px, py = win32api.GetCursorPos() Position_frame = get_val('Position_frame')
def Smart_chujia(): Position_frame = get_val('Position_frame') moni_on = get_val('moni_on') Click(Position_frame[4][0], Position_frame[4][1]) ##确认 price = smart_price() ##智能计算出价 set_val('userprice', price) ##保存用户出价 if moni_on: wx.CallAfter(pub.sendMessage, 'moni smartchujia', price=price) # wx.CallAfter(self.call, 1, ‘abc’, name=”ccc”, help=”test”) # wx.FutureCall(5000, self.call, ‘call after 100ms’, name=”test”) else: print("国拍智能出价") guopai_chujia(price) userprice = get_val('userprice')
def __init__(self, parent, moni): htmlpanel_size = get_val('htmlpanel_size') htmlpanel_pos = get_val('htmlpanel_pos') wx.Panel.__init__(self, parent, size=htmlpanel_size, pos=htmlpanel_pos, style=wx.BORDER_NONE) self.frame = self.GetTopLevelParent() self.titleBase = self.frame.GetTitle() htmlsize = get_val('htmlsize') webview_pos = get_val('webview_pos') self.webview = webview.WebView.New(self, size=htmlsize, pos=webview_pos, style=wx.BORDER_NONE) self.webview.EnableContextMenu(False) url_moni = get_val('url_moni') url_dianxin = get_val('url_dianxin') url_nodianxin = get_val('url_nodianxin') guopai_dianxin = get_val('guopai_dianxin') if moni: print("fsdfsfsfdsfsf") self.webview.LoadURL(url_moni) elif guopai_dianxin: self.webview.LoadURL(url_dianxin) print("352", url_dianxin) else: self.webview.LoadURL(url_nodianxin) print("Jfsd", url_nodianxin)
def Second_tijiao_time_smart(self, event): one_time2_smart = get_val('one_time2_smart') tem = self.second_tijiao_time_smart.GetValue() timelist = get_val('timelist') one_time2_smart3 = get_val('one_time2_smart3') if int(tem * 10) in timelist and tem >= one_time2_smart3: one_time2_smart = tem set_val('one_time2_smart', float(tem)) set_val('one_realtime2_smart', gettime(one_time2_smart)) # 计算得到的时间戳 print(gettime(one_time2_smart)) self.update_strategy() else: self.second_tijiao_time_smart3.SetValue(one_time2_smart)
def OnH_guopai_chujia(): Position_frame = get_val('Position_frame') lowest_price = get_val('lowest_price') one_diff = get_val('one_diff') set_val('yanzhengma_view', True) set_val('yanzhengma_count', 0) set_val('own_price1', lowest_price + one_diff) own_price1 = get_val('own_price1') setText(str(own_price1)) selfdelete() Click(Position_frame[1][0], Position_frame[1][1]) Click(Position_frame[1][0], Position_frame[1][1]) Click(Position_frame[6][0], Position_frame[6][1]) Click(Position_frame[6][0], Position_frame[6][1])
def run(self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range(1000000): a = time.clock() time.sleep(0.05) b = time.clock() a_time = get_val('a_time') true_time = get_val('true_time') a_time += b - a # 实际运行时间作为真实间隔f true_time += b - a set_val('a_time', a_time) set_val('true_time', true_time) one_real_time1 = get_val('one_real_time1') try: smartprice_tijiao = get_val('smartprice_tijiao') smartprice_chujia = get_val('smartprice_chujia') if one_real_time1 > a_time + 0.5: ##只要出现时间小于第一次出价就触发还原 # if not smartprice_chujia and not smartprice_tijiao: init_strategy() start_time = get_val('start_time') target_time = get_val('target_time') firststart_time = get_val('firststart_time') ##10点半 if start_time < a_time < target_time: ##11点到11点半之间 set_val("final_stage", True) else: set_val("final_stage", False) if firststart_time < true_time < start_time: ##10点半到11点之间 set_val("first_stage", True) else: set_val("first_stage", False) except: logger.exception("error message")
def __init__(self, parent): self.parent = parent x, y = parent.Position x0, y0 = get_val('CurrentStatusFramePos') CurrentStatusFrameSize = get_val('CurrentStatusFrameSize') super(CurrentStatusFrame, self).__init__(parent, size=CurrentStatusFrameSize, pos=(x + x0, y + y0), style=wx.FRAME_TOOL_WINDOW | wx.FRAME_FLOAT_ON_PARENT | wx.BORDER_NONE) self.currentstatuspanel = CurrentStatusPanel(self) # self.Bind(wx.EVT_ACTIVATE, self.print) self.Disable()