def find_drugs(code, batchno, num, index): print(code, num, index) global ishave_num # 添加明细 win32api.SetCursorPos([Pos.TJMX_X(), Pos.TJMX_Y()]) # 设置鼠标位置 win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) # 左键点击 win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) # 左键点击 time.sleep(1) pass # 药品编码搜索框 win32api.SetCursorPos([Pos.YPBMSS_X(), Pos.YPBMSS_Y()]) # 设置鼠标位置 win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) # 左键点击 win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) # 左键点击 time.sleep(0.1) pass # 清空输入框原有参数 win32api.keybd_event(win32con.VK_LCONTROL, 0, 0, 0) win32api.keybd_event(KEYJSON['A'], 0, 0, 0) win32api.keybd_event(KEYJSON['A'], 0, win32con.KEYEVENTF_KEYUP, 0) win32api.keybd_event(win32con.VK_LCONTROL, 0, win32con.KEYEVENTF_KEYUP, 0) pass # 把code转list,一个一个 输入进去 code_list = list(code) for value in code_list: if value in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': win32api.keybd_event(win32con.VK_SHIFT, 0, 0, 0) pass win32api.keybd_event(KEYJSON[value], 0, 0, 0) win32api.keybd_event(KEYJSON[value], 0, win32con.KEYEVENTF_KEYUP, 0) if value in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': win32api.keybd_event(win32con.VK_SHIFT, 0, win32con.KEYEVENTF_KEYUP, 0) pass pass # 点击搜索按钮 win32api.SetCursorPos([Pos.YPBMSSBTN_X(), Pos.YPBMSSBTN_Y()]) # 设置鼠标位置 win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) # 左键点击 win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) # 左键点击 time.sleep(1) pass # 全选订单明细 win32api.SetCursorPos([Pos.YPBMSSCHECK_X(), Pos.YPBMSSCHECK_Y()]) # 设置鼠标位置 win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) # 左键点击 win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) # 左键点击 time.sleep(1) pass img = ImageGrab.grab(Pos.SCREEN_IMAGE_POSITION()) px = img.load() for x in range(img.width): for y in range(img.height): if (str(px[x, y]) != str((255, 255, 255))): ishave_num = True break pass pass # 确定选中 win32api.SetCursorPos([Pos.SUREBTN_X(), Pos.SUREBTN_Y()]) # 设置鼠标位置 win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) # 左键点击 win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) # 左键点击 time.sleep(1) pass if ishave_num: # 初始化tab焦点 win32api.SetCursorPos([Pos.FIRSTDATA_X(), Pos.FIRSTDATA_Y()]) # 设置鼠标位置 DOUBLE_CLICK() time.sleep(0.5) count = 0 # while count < 5 * index + 1: while count < 5 * index + 2: # 2.0 TAB_KEYUP() count += 1 pass time.sleep(0.5) # 把code转list,一个一个 输入进去 batch_list = list(batchno) print(batch_list) for value in batch_list: if value in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': win32api.keybd_event(win32con.VK_SHIFT, 0, 0, 0) pass if value == '-': print(KEYJSON[value]) win32api.keybd_event(KEYJSON[value], 0, 0, 0) win32api.keybd_event(KEYJSON[value], 0, win32con.KEYEVENTF_KEYUP, 0) if value in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': win32api.keybd_event(win32con.VK_SHIFT, 0, win32con.KEYEVENTF_KEYUP, 0) pass pass TAB_KEYUP() num_list = list(str(int(num))) for value in num_list: win32api.keybd_event(KEYJSON[value], 0, 0, 0) win32api.keybd_event(KEYJSON[value], 0, win32con.KEYEVENTF_KEYUP, 0) pass time.sleep(0.5) TAB_KEYUP() print(code, num) pass
if '东莞交易' in windows[item][2]: print(windows[item]) win_id = item print(win32gui.GetWindowRect(win_id)) print(win32gui.GetWindowText(win_id)) win32api.PostMessage(win_id, win32con.WM_SYSCOMMAND, win32con.SC_MAXIMIZE, 0) print('-------------------------------------------------') win32gui.SetForegroundWindow(win_id) time.sleep(1) now_hWnd = win32gui.WindowFromPoint( (int(Pos.SCREEN_X / 2), int(Pos.SCREEN_Y / 2))) (Pos.now_hWnd_X1, Pos.now_hWnd_Y1, Pos.now_hWnd_X2, Pos.now_hWnd_Y2) = win32gui.GetWindowRect(now_hWnd) break pass print('-------------------------------------------------') print('-------------------------------------------------') print(Pos.now_hWnd_X1) print(Pos.now_hWnd_Y1) print(Pos.now_hWnd_X2) print(Pos.now_hWnd_Y2) print(Pos.TJMX_X()) print(Pos.TJMX_Y()) win32api.SetCursorPos([Pos.TJMX_X(), Pos.TJMX_Y()]) # 设置鼠标位置 win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) # 左键点击 win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) # 左键点击