def buy(self, stock_no, amount, price): price = '%.3f' % float(price) hot_key(['F1']) time.sleep(sleep_time) hwnd = self.get_right_hwnd() ctrl = win32gui.GetDlgItem(hwnd, 0x408) set_text(ctrl, stock_no) time.sleep(sleep_time) ctrl = win32gui.GetDlgItem(hwnd, 0x409) set_text(ctrl, price) time.sleep(sleep_time) ctrl = win32gui.GetDlgItem(hwnd, 0x40A) set_text(ctrl, str(amount)) time.sleep(sleep_time) hot_key(['enter']) time.sleep(sleep_time) result = None retry = 0 while not result and retry < retry_time: retry += 1 time.sleep(sleep_time) hot_key(['y']) time.sleep(sleep_time) result = self.get_result() hot_key(['enter']) return result
def close_remainder_window(self): """ 关闭登录后的“营业部公告”提示框 :return: """ remainder_hwnd = None exp_count = 0 while remainder_hwnd is None or remainder_hwnd != 0: remainder_hwnd = win32gui.FindWindowEx(None, remainder_hwnd, '#32770', None) try: title_item = win32gui.GetDlgItem(remainder_hwnd, 0x555) if title_item == 0: continue if win32gui.GetWindowText(title_item) != '营业部公告': continue no_show_msg_item = win32gui.GetDlgItem(remainder_hwnd, 0x525) if no_show_msg_item != 0: # win32gui.PostMessage(no_show_msg_item, win32con.BM_CLICK, 0, 0) win32gui.PostMessage(no_show_msg_item, win32con.BM_SETCHECK, 1, 0) cmf_btn_item = win32gui.GetDlgItem(remainder_hwnd, 0x1) if cmf_btn_item != 0: win32gui.PostMessage(cmf_btn_item, win32con.BM_CLICK, 0, 0) win32gui.CloseWindow(cmf_btn_item) return exp_count = 0 except pywintypes.error: exp_count += 1 if exp_count >= 100: break
def buy(self, stock_no, amount, price): hot_key(['F1']) time.sleep(sleep_time) hwnd = self.get_right_hwnd() ctrl = win32gui.GetDlgItem(hwnd, 0x408) set_text(ctrl, stock_no) time.sleep(sleep_time) if price is not None: time.sleep(sleep_time) price = '%.3f' % price ctrl = win32gui.GetDlgItem(hwnd, 0x409) set_text(ctrl, price) time.sleep(sleep_time) ctrl = win32gui.GetDlgItem(hwnd, 0x40A) set_text(ctrl, str(amount)) time.sleep(sleep_time) hot_key(['enter']) result = None retry = 0 while retry < retry_time: time.sleep(sleep_time) result = self.get_result() if result: hot_key(['enter']) return result hot_key(['y']) retry += 1 return { 'code': 2, 'status': 'unknown', 'msg': '获取结果失败,请自行确认订单状态', }
def try_manual_login(password, cert_password): hwnd = find_window("Open API Login") if hwnd == 0: return edit_pass = win32gui.GetDlgItem(hwnd, 0x3E9) edit_cert = win32gui.GetDlgItem(hwnd, 0x3EA) button = win32gui.GetDlgItem(hwnd, 0x1) # 비밀번호 입력 try: enter_keys(edit_pass, password) except: pass # 인증비밀번호입력 try: enter_keys(edit_cert, cert_password) except: pass # 버튼 클릭 try: click_button(button) except: pass
def getBuyAmount(self, code='600000', percent=0.99): entrust_window_hwnd = win32gui.GetDlgItem(self.operate_frame_hwnd, 0xE901) # 委托窗口框架 # win32gui.SetWindowPos(entrust_window_hwnd, win32con.HWND_TOPMOST, 0, 0, 0, 0, # win32con.SWP_NOMOVE | win32con.SWP_NOACTIVATE | win32con.SWP_NOOWNERZORDER | win32con.SWP_SHOWWINDOW) self.clickF6() self.clickF1() # self.buy_stock_code_hwnd = win32gui.GetDlgItem(entrust_window_hwnd, 0x40B) # 卖出代码输入框 win32gui.PostMessage(self.refresh_entrust_hwnd, win32con.BM_CLICK, None, None) time.sleep(0.4) win32gui.SendMessage(self.buy_stock_code_hwnd, win32con.WM_SETTEXT, None, code) # 输入卖出代码 buff = ctypes.create_unicode_buffer(32) # full_satisfed_buy_str = win32gui.GetDlgItemText(entrust_window_hwnd, 0x3FA) win32gui.SendMessage(win32gui.GetDlgItem(entrust_window_hwnd, 0x3FA), win32con.WM_GETTEXT, 32, buff) full_satisfed_buy_str = buff.value # print(buff.value) # 读取文本 # print(win32gui.GetWindowText(win32gui.GetDlgItem(entrust_window_hwnd, 0x3FA))) full_satisfed_buy_num = 0.0 # buy_num = 0.0 if not full_satisfed_buy_str == "": full_satisfed_buy_num = float(full_satisfed_buy_str) buy_num = int(full_satisfed_buy_num * percent / 100) * 100 return buy_num, int(full_satisfed_buy_num)
def readMOHAA(): try: print("Looking for MOHAA.") # Find the MOH console window hwnd = win32gui.FindWindow("MOHTA WinConsole", None) win32gui.ShowWindow(hwnd, win32con.SW_SHOW) clearBtn = win32gui.FindWindowEx(hwnd, None, "Button", "clear") # Click the clear button win32gui.SendMessage(hwnd, win32con.WM_COMMAND, 1, clearBtn) #Set cmdline with serverinfo cmdline = win32gui.GetDlgItem(hwnd, 101) win32gui.SendMessage(cmdline, win32con.WM_SETTEXT, None, "clientinfo") win32gui.PostMessage(cmdline, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0) #Get console info console = win32gui.GetDlgItem(hwnd, 100) buffer = win32gui.PyMakeBuffer(25555) length = win32gui.SendMessage(console, win32con.WM_GETTEXT, 25555, buffer) result = buffer[0:length * 2].tobytes().decode("UTF-16") time.sleep(2) # Click the clear button win32gui.SendMessage(hwnd, win32con.WM_COMMAND, 1, clearBtn) # split on newline splitted = result.splitlines() for index, value in enumerate(splitted): if "Server: " in value: print("Found server! " + value[8:]) return value[8:] except Exception as e: print("Error[MOHSH]: " + str(e))
def relate(self): #获取窗口左上角和右下角坐标 hwndFileLock = win32gui.FindWindow( None, "FileLock Test - ESAFENET(http://www.esafenet.com)") if (hwndFileLock): print('find hwndFileLock Window handle = %X' % hwndFileLock) hBtnStartRelate = win32gui.GetDlgItem(hwndFileLock, 0x41C) win32gui.SendMessage(hBtnStartRelate, win32con.WM_LBUTTONDOWN) win32gui.PostMessage(hBtnStartRelate, win32con.WM_LBUTTONUP) #time.sleep(0.1) #win32api.keybd_event(13, 0 ) #win32api.keybd_event(13, 0, win32con.KEYEVENTF_KEYUP, 0) time.sleep(0.5) hwndDlgOk = win32gui.FindWindow(None, "Iotest64") if (hwndDlgOk == 0): hwndDlgOk = win32gui.FindWindow(None, "Iotest") if (hwndDlgOk): hBtnDlgOkBtnOK = win32gui.GetDlgItem(hwndDlgOk, 0x2) win32gui.SendMessage(hBtnDlgOkBtnOK, win32con.WM_LBUTTONDOWN) win32gui.SendMessage(hBtnDlgOkBtnOK, win32con.WM_LBUTTONUP) time.sleep(0.2) hBtnFilterStop = win32gui.GetDlgItem(hwndFileLock, 0x3E8) win32gui.SendMessage(hBtnFilterStop, win32con.WM_LBUTTONDOWN) win32gui.SendMessage(hBtnFilterStop, win32con.WM_LBUTTONUP) time.sleep(0.2) hBtnLogStop = win32gui.GetDlgItem(hwndFileLock, 0x3EB) win32gui.SendMessage(hBtnLogStop, win32con.WM_LBUTTONDOWN) win32gui.SendMessage(hBtnLogStop, win32con.WM_LBUTTONUP)
def GetControl(self, control_id=None): control_id = control_id or self.control_id try: h = win32gui.GetDlgItem(self.window.hwnd, control_id) except: hparent = win32gui.GetParent(self.window.hwnd) hparent = win32gui.GetParent(hparent) h = win32gui.GetDlgItem(hparent, control_id) return h
def OnShowPos(self, hwnd, msg, wparam, lparam): ctrl = win32gui.GetDlgItem(self.hwnd, IDC_SEARCHTEXT) s = str(win32api.HIWORD(wparam)) + ', ' + str(win32api.LOWORD(wparam)) s += " " s += str(win32api.HIWORD(lparam)) + ', ' + str(win32api.LOWORD(lparam)) win32gui.SetWindowText(ctrl, s) ctrl2 = win32gui.GetDlgItem(self.hwnd, IDC_STATUS) s = str(win32api.HIWORD(lparam) - win32api.HIWORD(wparam)) + ', ' + str( win32api.LOWORD(lparam) - win32api.LOWORD(wparam)) win32gui.SetWindowText(ctrl2, s)
def get_add_acc_handles(self): #trade_main_hwnd = win32gui.FindWindow(0, self.Title) # 交易窗口 #operate_frame_hwnd = win32gui.GetDlgItem(trade_main_hwnd, 59648) # 操作窗口框架 tool_menu_hwnd = win32gui.GetDlgItem(self.trade_main_hwnd, 59392) # 工具栏窗口框架 tool_menu_hwnd_sub = dumpWindow(tool_menu_hwnd) add_acc_hwnd = win32gui.GetDlgItem(tool_menu_hwnd_sub[0][0], 1691) # 工具栏添加账户按钮 clickButton(add_acc_hwnd) new_add_acc_login_hwnd = win32gui.FindWindow(0, '用户登录') # 交易窗口 print('new_add_acc_login_hwnd=', new_add_acc_login_hwnd) return add_acc_hwnd """
def _grab_verify_code(self): verify_code_hwnd = win32gui.GetDlgItem(self.login_hwnd, 0x56ba) self._set_foreground_window(self.login_hwnd) time.sleep(1) rect = win32gui.GetWindowRect(verify_code_hwnd) return ImageGrab.grab(rect)
def cancel(self, entrust_no): hot_key(['F3']) time.sleep(sleep_time) self.refresh() hwnd = self.get_right_hwnd() ctrl = win32gui.GetDlgItem(hwnd, 0x417) self.copy_table(ctrl) data = None retry = 0 while not data and retry < retry_time: retry += 1 time.sleep(sleep_time) data = get_clipboard_data() if data: entrusts = parse_table(data) find = None for i, entrust in enumerate(entrusts): if str(entrust['合同编号']) == str(entrust_no): find = i break if find is None: return {'code': 1, 'status': 'failed', 'msg': u'没找到指定订单'} left, top, right, bottom = win32gui.GetWindowRect(ctrl) x = 50 + left y = 30 + 16 * find + top win32api.SetCursorPos((x, y)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) time.sleep(sleep_time) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) time.sleep(sleep_time) hot_key(['enter']) return {'code': 0, 'status': 'succeed'} return {'code': 1, 'status': 'failed'}
def get_new_desktop_name(parent_hwnd): """ Create a dialog box to ask the user for name of desktop to be created """ msgs = { win32con.WM_COMMAND: desktop_name_dlgproc, win32con.WM_CLOSE: desktop_name_dlgproc, win32con.WM_DESTROY: desktop_name_dlgproc } # dlg item [type, caption, id, (x,y,cx,cy), style, ex style style = win32con.WS_BORDER | win32con.WS_VISIBLE | win32con.WS_CAPTION | win32con.WS_SYSMENU ## |win32con.DS_SYSMODAL h = win32gui.CreateDialogIndirect(win32api.GetModuleHandle(None), [ ['One ugly dialog box !', (100, 100, 200, 100), style, 0], [ 'Button', 'Create', win32con.IDOK, (10, 10, 30, 20), win32con.WS_VISIBLE | win32con.WS_TABSTOP | win32con.BS_HOLLOW | win32con.BS_DEFPUSHBUTTON ], [ 'Button', 'Never mind', win32con.IDCANCEL, (45, 10, 50, 20), win32con.WS_VISIBLE | win32con.WS_TABSTOP | win32con.BS_HOLLOW ], ['Static', 'Desktop name:', 71, (10, 40, 70, 10), win32con.WS_VISIBLE], ['Edit', '', 72, (75, 40, 90, 10), win32con.WS_VISIBLE] ], parent_hwnd, msgs) ## parent_hwnd, msgs) win32gui.EnableWindow(h, True) hcontrol = win32gui.GetDlgItem(h, 72) win32gui.EnableWindow(hcontrol, True) win32gui.SetFocus(hcontrol)
def _click_login_button(self): time.sleep(0.5) try: input_hwnd = win32gui.GetDlgItem(self.login_hwnd, 0x3EE) win32gui.SendMessage(input_hwnd, win32con.BM_CLICK, None, None) except Exception: return None
def CreateContact(btnProcessor,*args): b = check() if not b: return partner = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[4]) combo = win32gui.GetDlgItem(btnProcessor.window.hwnd, btnProcessor.other_ids[4]) sel = win32gui.SendMessage(combo, win32con.CB_GETCURSEL) name = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[0]) email = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[1]) office_no = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[2]) mobile_no = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[3]) if not name: win32ui.MessageBox("Please enter name.", "Create Contact", flag_stop) return res = {'name':ustr(name), 'email':ustr(email), 'phone':ustr(office_no), 'mobile':ustr(mobile_no)} try: id = NewConn.CreateContact(sel, str(res)) msg="New contact created for partner '%s'."%partner except Exception,e: msg="Contact not created \n\n" + getMessage(e) win32ui.MessageBox(msg, "Create Contact", flag_error) return
def _DoSize(self, cx, cy, repaint=1): # right-justify the textbox. ctrl = win32gui.GetDlgItem(self.hwnd, IDC_SEARCHTEXT) l, t, r, b = win32gui.GetWindowRect(ctrl) l, t = win32gui.ScreenToClient(self.hwnd, (l, t)) r, b = win32gui.ScreenToClient(self.hwnd, (r, b)) win32gui.MoveWindow(ctrl, l, t, cx - l - 5, b - t, repaint)
def UpdateControl_FromValue(self): combo = self.GetControl() conn = self.func() list = conn.GetDBList() db = conn.getitem('_dbname') if list == -1: hinst = win32gui.dllhandle parent = self.window.hwnd dwStyle = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_TABSTOP | win32con.WS_BORDER | \ win32con.ES_AUTOHSCROLL | win32con.FF_ROMAN | win32con.FW_EXTRALIGHT hwndImg = win32gui.CreateWindow("EDIT", db, dwStyle, 67, 80, 180, 20, parent, 7000, 0, None) self.active_control_id = 7000 win32gui.ShowWindow(combo, False) else: try: txtbx = win32gui.GetDlgItem(self.window.hwnd, 7000) win32gui.DestroyWindow(txtbx) except Exception, e: pass win32gui.ShowWindow(combo, True) win32gui.SendMessage(combo, win32con.CB_RESETCONTENT, 0, 0) for item in list: win32gui.SendMessage(combo, win32con.CB_ADDSTRING, 0, str(item)) sel = win32gui.SendMessage(combo, win32con.CB_SELECTSTRING, 0, db) if sel == -1: win32gui.SendMessage(combo, win32con.CB_SETCURSEL, 0, 0) self.active_control_id = self.control_id
def MakeAttachment(btnProcessor,*args): #Check if server running or user logged in b = check() if not b: return ex = btnProcessor.window.manager.outlook.ActiveExplorer() assert ex.Selection.Count == 1 mail = ex.Selection.Item(1) mail = GetMail(btnProcessor) #get selected records hwndList = win32gui.GetDlgItem(btnProcessor.window.hwnd, btnProcessor.other_ids[0]) r = GetSelectedItems(hwndList) if not r: win32ui.MessageBox("No records selected", "Make Attachment", flag_info) return try: NewConn.ArchiveToOpenERP(r,mail) msg="Mail archived to OpenERP." flag = flag_info except Exception,e: msg = "Attachment not created \n\n" + getMessage(e) flag = flag_error
def AddNewObject(btnProcessor,*args): #Check if server running or user logged in b = check() if not b: return #Check if title or object not specified obj_title = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[0]) obj_name = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[1]) if not obj_title: win32ui.MessageBox("No Title specified", "", flag_excl) return if not obj_name: win32ui.MessageBox("No object specified", "", flag_excl) return #Check if object does not exist in the database or it already exist in the list try: all_obj_list = NewConn.GetAllObjects() curr_obj_list = [obj[1] for obj in NewConn.GetObjList()] curr_title_list = [obj[0] for obj in NewConn.GetObjList()] if obj_name not in all_obj_list: win32ui.MessageBox("No such object exists", "Object Settings", flag_excl) return elif obj_name in curr_obj_list: win32ui.MessageBox("Object already in the list", "Object Settings", flag_info) return elif obj_title in curr_title_list: win32ui.MessageBox("Title already in the list. Please give different title", "Object Settings", flag_excl) return #extract image path and load the image image_path='' image_path = os.path.join(btnProcessor.window.manager.application_directory, "dialogs\\resources\\openerp_logo1.bmp") path=win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[2]) if path: image_path = path load_bmp_flags=win32con.LR_LOADFROMFILE | win32con.LR_LOADTRANSPARENT try: hicon = win32gui.LoadImage(0, image_path,win32con.IMAGE_BITMAP, 40, 40, load_bmp_flags) except Exception,e: msg=getMessage(e) hicon=None win32ui.MessageBox(msg, "Load Image", flag_error) #Add the object in the list win32gui.ImageList_Add(il,hicon,0) cnt = win32gui.ImageList_GetImageCount(il) hwndList = win32gui.GetDlgItem(btnProcessor.window.hwnd, btnProcessor.other_ids[3]) num_items = win32gui.SendMessage(hwndList, commctrl.LVM_GETITEMCOUNT) item = LVITEM(text=obj_title, iImage=cnt-2, iItem = num_items) new_index = win32gui.SendMessage(hwndList, commctrl.LVM_INSERTITEM, 0, item.toparam()) win32gui.SendMessage(hwndList, commctrl.LVM_SETIMAGELIST, commctrl.LVSIL_SMALL, il) item = LVITEM(text=obj_name, iItem = new_index, iSubItem = 1) win32gui.SendMessage(hwndList, commctrl.LVM_SETITEM, 0, item.toparam()) NewConn.InsertObj(obj_title,obj_name,image_path)
def _set_login_password(self, password): time.sleep(0.5) try: input_hwnd = win32gui.GetDlgItem(self.login_hwnd, 0x3F4) win32gui.SendMessage(input_hwnd, win32con.WM_SETTEXT, None, password) except Exception: return
def show_window(self): """ Show the change time dialog window """ if self.hwnd is None: self.__create_window() else: win32gui.BringWindowToTop(self.hwnd) win32gui.SetWindowText( win32gui.GetDlgItem(self.hwnd, self.resources.ids['IDC_HOURS']), str(int(self.minutes / 60))) win32gui.SetWindowText( win32gui.GetDlgItem(self.hwnd, self.resources.ids['IDC_MINUTES']), str(self.minutes % 60))
def get_time(self): """ Get the current logged number of minutes :return: Number of minutes """ if self.hwnd is not None: minutes = 60 * int( win32gui.GetWindowText( win32gui.GetDlgItem(self.hwnd, self.resources.ids['IDC_HOURS']))) minutes += int( win32gui.GetWindowText( win32gui.GetDlgItem( self.hwnd, self.resources.ids['IDC_MINUTES']))) self.minutes = minutes return self.minutes
def vmunpacker(Path): print(Path) while True: try: main_app="VMUnpacker V1.3 Public Version" hwnd=win32gui.FindWindow(None,main_app) win32gui.SetForegroundWindow(hwnd) #'...' button button1 = win32gui.GetDlgItem(hwnd, 0x000003E8) #'unpack' button button2 = win32gui.GetDlgItem(hwnd, 0x000003E9) #'파일 name' File_paths = win32gui.GetDlgItem(hwnd, 0x000003EC) click_MouseLbtn(button1) time.sleep(1) main_app2="열기" hwnd2=win32gui.FindWindow(None,main_app2) #win32api.SendMessage #FilePath2 File_paths2 = win32gui.GetDlgItem(hwnd2,0x0000047C) time.sleep(0.5) #'파일열기' button button3 = win32gui.GetDlgItem(hwnd2, 0x00000001) SendMessage = ctypes.windll.user32.SendMessageW SendMessage(File_paths2, 0xC, 0, Path) time.sleep(0.5) #win32gui.EnumChildWindows(hwnd, winfun, None) click_MouseLbtn(button3) click_MouseLbtn(button2) time.sleep(10) return except: time.sleep(5) continue
def _set_communication_password(self, communication): ##not finished time.sleep(0.4) # input_hwnd = win32gui.FindWindowEx(self.login_hwnd, 1, 'Edit', None) # 获取hld下第一个为edit控件的句柄 try: input_hwnd = win32gui.GetDlgItem(self.login_hwnd, 0x3E9) win32gui.SendMessage(input_hwnd, win32con.WM_SETTEXT, None, communication) except Exception: return
def set_time(self, minutes): """ Set the current logged number of minutes :param minutes: Number of minutes """ self.minutes = minutes if self.hwnd is not None: win32gui.SetWindowText( win32gui.GetDlgItem(self.hwnd, self.resources.ids['IDC_HOURS']), str(int(self.minutes / 60))) win32gui.SetWindowText( win32gui.GetDlgItem(self.hwnd, self.resources.ids['IDC_MINUTES']), str(self.minutes % 60)) if self.time_changed_callback is not None: self.time_changed_callback(minutes)
def set_auto_on(password): hwnd = find_window("계좌비밀번호") # 비밀번호등록 edit = win32gui.GetDlgItem(hwnd, 0xCA) enter_keys(edit, password) win32api.Sleep(100) button_register_all = win32gui.GetDlgItem(hwnd, 0xCE) click_button(button_register_all) # 체크박스 체크 checkbox = win32gui.GetDlgItem(hwnd, 0xCD) checked = win32gui.SendMessage(checkbox, win32con.BM_GETCHECK) if not checked: win32gui.SendMessage(checkbox, win32con.BM_SETCHECK, 0) # 닫기 버튼 클릭 button= win32gui.GetDlgItem(hwnd, 0x01) click_button(button)
def get_balance(self): hot_key(['F4']) time.sleep(sleep_time) self.refresh() hwnd = self.get_right_hwnd() result = {} for key, cid in BALANCE_CONTROL_ID_GROUP.items(): ctrl = win32gui.GetDlgItem(hwnd, cid) result[key] = get_text(ctrl) return result
def set_auto_off(): try: hwnd = find_window("계좌비밀번호") # 체크박스 해제 checkbox = win32gui.GetDlgItem(hwnd, 0xCD) checked = win32gui.SendMessage(checkbox, win32con.BM_GETCHECK) if checked: win32gui.SendMessage(checkbox, win32con.BM_SETCHECK, 0) # 닫기 버튼 클릭 button = win32gui.GetDlgItem(hwnd, 0x01) click_button(button) except: print("auto 해제 실패") print("auto 해제 후 대기 중") time.sleep(5)
def hwnd_buy(wdname): main_hwnd = win32gui.FindWindow(None, wdname) hwnd_01 = win32gui.GetDlgItem(main_hwnd, int(ID_1, 16)) hwnd_02 = win32gui.GetDlgItem(hwnd_01, int(ID_2, 16)) hwnd_buy_list = [ win32gui.GetDlgItem(hwnd_02, int(ID_code, 16)), win32gui.GetDlgItem(hwnd_02, int(ID_name, 16)), win32gui.GetDlgItem(hwnd_02, int(ID_buyInPrice, 16)), win32gui.GetDlgItem(hwnd_02, int(ID_accNum, 16)), win32gui.GetDlgItem(hwnd_02, int(ID_buyNUm, 16)), win32gui.GetDlgItem(hwnd_02, int(ID_buyButton, 16)) ] return hwnd_buy_list
def input_string(title, item_id, string, callback=None): print(title + "find...") title_hwnd = win32gui.FindWindow(None, title) print(title + " item find...") item_hwnd = win32gui.GetDlgItem(title_hwnd, item_id) for c in string: win32api.SendMessage(item_hwnd, win32con.WM_CHAR, ord(c), 0) if callback is not None and str(type(callback)) == "<class 'function'>": print("start " + callback) time.sleep(1) callback()