def lookupWindow(): idle=0 while(True): print("=================") try: wins=findwindows.find_windows() for win in wins: try: title=handleprops.text(win) print(title) if title!=None: if "FTDI" in title: print("--------------------find:"+title) if treatadlink(win): idle=0 elif "设备驱动程序" in title: print("、、、、、、、、、、、find:"+title) if treatQudong(win): idle=0 except UnicodeEncodeError as e: print(e) pass time.sleep(1)#每秒检查一次 idle+=1 if idle>5 :#连续五秒没有查找到窗口则退出 break except: traceback.print_exc() a=input("except")
def isActive(self): hwnd = win32gui.GetForegroundWindow() if not self._gameHWND: # @todo: find game automatically if 0 <= handleprops.text(hwnd).lower().find('path of exile'): self._gameHWND = hwnd return self._gameHWND
def get_values(self): """ values from windows """ #windows = findwindows.find_windows(parent = self.window)#, class_name = 'Edit') win_ctrl = {} for hwnd in self.child_windows: parent = handleprops.parent(hwnd) parent_text = handleprops.text(parent) ### picked tab if parent_text in ['Serial Bridge', 'Proxy']: if parent_text not in win_ctrl: win_ctrl[parent_text] = {} classname = handleprops.classname(hwnd) if classname in ['Edit']: text = handleprops.text(hwnd) rect = handleprops.rectangle(hwnd) #log.debug("%s,%s,%s - %s" % (parent, classname, text, parent_text)) #log.debug("(%s,%s)" % (rect.top, rect.left)) #val = (rect.top, rect.left) win_ctrl[parent_text][(rect.top, rect.left)] = text if len(win_ctrl) == 0: raise (NoDataException('no data found')) for key in win_ctrl: log.info(key) data = win_ctrl[key] log.info(data) ### sort by (top, left) #(y,x) vals = sorted(data.items(), key=lambda item: item[0]) #log.debug(vals) for i, item in enumerate(vals, 1): line = "%s:%s" % (i, item[1]) #log.debug(line) self.g.msg_queue.put(line)
def checkStuff(): app = Application(backend="win32").connect( path=r"C:\DM54_W16\DM54_W16.exe") winChildren = "" dialogs = app.windows() for x in dialogs: if handleprops.classname(x) == "WinDevObject": winChildren = handleprops.children(x) topWindow = x break for x in winChildren: if handleprops.text(x) == E1.get(): rects[0] = handleprops.rectangle(x) if handleprops.text(x).replace(",", "") == E2.get(): rects[1] = handleprops.rectangle(x) if handleprops.text(x) == E3.get(): rects[2] = handleprops.rectangle(x) if handleprops.text(x) == E4.get(): rects[3] = handleprops.rectangle(x) writeRects(rects)
def list_windows(self): """ Returns a list of current open windows. Invalid elements such as '' and None are removed. Windows O.S ONLY! """ hwnds = findwindows.find_windows() names = [handleprops.text(hwnd) for hwnd in hwnds] while '' in names: names.remove('') while None in names: names.remove(None) logging.debug('Detected following windows: {}'.format(names)) names.append('') return names
def get_window_info(): all_window_handles = findwindows.enum_windows() for window_handle in all_window_handles: if handleprops.isvisible(window_handle): pos_x = handleprops.rectangle(window_handle).left pos_y = handleprops.rectangle(window_handle).top size_x = handleprops.rectangle(window_handle).width() size_y = handleprops.rectangle(window_handle).height() title_name = handleprops.text(window_handle) class_name = handleprops.classname(window_handle) pid = handleprops.processid(window_handle) date_time = datetime.datetime.now() # Note: Minimized windows have negative pos_x and pos_y values (and smaller sizes). window_info = [ pos_x, pos_y, size_x, size_y, title_name, class_name, pid, date_time ] window_db_id = database.create_window_record(window_info) logger.info( 'OpenWindow record created in database (db_id %i).' % window_db_id)
def test_text(self): """Make sure the text method returns correct result""" self.assertEquals("Untitled - Notepad", text(self.dlghandle)) self.assertEquals("", text(self.edit_handle))
def get_values(self): """ values from windows """ #windows = findwindows.find_windows(parent = self.window)#, class_name = 'Edit') win_ctrl = {} values = [] for hwnd in self.child_windows: parent = handleprops.parent(hwnd) parent_text = handleprops.text(parent) ### picked tab if parent_text in [ 'Serial Bridge', 'Proxy']: if parent_text not in win_ctrl: win_ctrl[parent_text] = {} classname = handleprops.classname(hwnd) if classname in ['Edit']: text = handleprops.text(hwnd) rect = handleprops.rectangle(hwnd) #log.debug("%s,%s,%s - %s" % (parent, classname, text, parent_text)) #log.debug("(%s,%s)" % (rect.top, rect.left)) #val = (rect.top, rect.left) win_ctrl[parent_text][(rect.top, rect.left)] = text if len(win_ctrl) == 0: raise(NoDataException('no data found')) for key in win_ctrl: log.info(key) data = win_ctrl[key] log.info(data) ### sort by (top, left) #(y,x) vals = sorted(data.items(),key=lambda item: item[0]) #log.debug(vals) fields = {} for i, item in enumerate(vals, 1): #line = "%s:%s" % (i, item[1]) #log.debug(line) fields[i] = item[1] log.debug(self.conf[self.channel]) """ sensu-monitoring-platform event: - action - occurrences [redis] - client -- name -- address -- timestamp - check -- name -- issued -- subscirbers [] -- handler -- history [] -- interval -- output -- command -- status """ ### msg values.append(fields) #log.debug('=='*20) return values
def get_text_value(self, hwnd): """ get text from Edit """ return handleprops.text(hwnd)
def test_text(self): "Make sure the text method returns correct result" self.assertEquals("Untitled - Notepad", text(self.dlghandle)) self.assertEquals("", text(self.edit_handle))
def Last_Second_Save(): # start = time.time() hndls = None hndls = findwindows.find_windows() imgs = None imgs = [] for hndl in hndls: if ((handleprops.exstyle(hndl) == 256 or handleprops.exstyle(hndl) == 786688 or handleprops.exstyle(hndl) == 262400 or handleprops.exstyle(hndl) == 65792 or handleprops.exstyle(hndl) == 2097408 or handleprops.exstyle(hndl) == 262416 or handleprops.exstyle(hndl) == 327937 or handleprops.exstyle(hndl) == 0) and not (handleprops.text(hndl) == None or handleprops.text(hndl) == "")): print( str(handleprops.text(hndl)) + " - " + str(handleprops.exstyle(hndl))) if (str(handleprops.text(hndl)).strip() == ""): continue else: try: app = None app = hwndwrapper.HwndWrapper(hndl) # app.set_focus() win32functions.WaitGuiThreadIdle(hndl) if app.is_minimized(): app.restore() time.sleep(0.25) win32functions.WaitGuiThreadIdle(hndl) app.set_focus() win32functions.WaitGuiThreadIdle(hndl) rect = None rect = handleprops.rectangle(hndl) win32functions.WaitGuiThreadIdle(hndl) box = None box = (rect.left, rect.top, rect.right, rect.bottom) img = None img = getRectAsImage(box) imgs.append(img) # time.sleep(0.1) except: # print("ERROR --- "+(str(handleprops.text(hndl)) + " - " + str(handleprops.processid(hndl)))) # print("Unexpected error:", sys.exc_info()[0]) continue #START IF# if len(imgs) > 0: sqrt = math.sqrt(len(imgs)) # print(sqrt) if sqrt > int(sqrt): if len(imgs) == 1: matrix_col, matrix_row = (1, 1) else: matrix_col, matrix_row = (int(sqrt), int(sqrt)) addition = [0] while (matrix_col * matrix_row) < len(imgs): if (addition[0] == 0): matrix_col += 1 addition[0] = 1 else: matrix_row += 1 addition[0] = 0 else: matrix_col, matrix_row = (int(sqrt), int(sqrt)) # print("MATRIX: " + str(matrix_row) + "x" + str(matrix_col)) finalRes_width = 960 * matrix_col finalRes_height = 540 * matrix_row result = Image.new("RGB", (finalRes_width, finalRes_height)) # print("RESULT IMAGE SIZE: " + str(result.size)) perImg_width = 960 perImg_height = 540 lst_counter = 0 # print("NUMBER OF IMGS: " + str(len(imgs))) for col in range(matrix_col): for row in range(matrix_row): if len(imgs) > lst_counter: imgs[lst_counter].thumbnail((perImg_width, perImg_height), Image.LANCZOS) x = col * perImg_width y = row * perImg_height w, h = imgs[lst_counter].size result.paste(imgs[lst_counter], (x, y, x + w, y + h)) lst_counter += 1 now = datetime.now() name = ("LastSecondSave-" + str(now.year) + "-" + str(now.month) + "-" + str(now.day) + "-" + str(now.hour) + "-" + str(now.minute)) homeDir = os.path.expanduser("~") if os.path.isdir(homeDir + "\\LastSecondSave"): result.save(homeDir + "\\LastSecondSave\\" + name + ".jpg") else: os.mkdir(homeDir + "\\LastSecondSave") result.save(homeDir + "\\LastSecondSave\\" + name + ".jpg")
def test_text(self): """Make sure the text method returns correct result""" self.assertEqual("Untitled - Notepad", text(self.dlghandle)) self.assertEqual("", text(self.edit_handle)) self.assertEqual(None, text(sys.maxsize)) self.assertEqual(None, text(None))
locateOnScreen, locateCenterOnScreen, \ moveTo, moveRel, click, hotkey from pywinauto import \ handleprops, win32functions, keyboard __author__ = '墨焓 <*****@*****.**>' __program__ = 'dota2 lib' __version__ = 'demo' _logger = logging.getLogger(__program__) button_of_accept = 'button_of_accept.png' box_of_game_ready = 'box_of_game_ready.png' fg_window = win32functions.GetForegroundWindow fgw_title = lambda: handleprops.text(fg_window()) fgw_class = lambda: handleprops.classname(fg_window()) def dota2_accept_game_and_switch_back(): hotkey('enter') hotkey('alt', 'tab') class Dota2Controller: TIME_SLOT = 0.1 POLL_INTERVAL_MAX = 10 WINDOW_INFO = {'title': 'Dota 2', 'class': 'SDL_app', 'program': 'dota2.exe'} # WINDOW_INFO = {'class': 'HoneyviewClassX'} poll_interval = TIME_SLOT
def _set_properties(self, handle_id): """ * set the instance's properties """ self.set_title(handleprops.text(handle_id))
def setupDM(container): rects = readRects() app = Application(backend="win32").connect( path=r"C:\DM54_W16\DM54_W16.exe") # top_windows = [] # EnumWindows(windowEnumerationHandler, top_windows) # for i in top_windows: # if 'Dispatch-Mate' in i[1]: # SetWindowPos(i[0], None, 0, 0, 1920, 1080, SWP_SHOWWINDOW) # SetForegroundWindow(i[0]) winChildren = "" dialogs = app.windows() click(50, 365) fore = win32gui.GetForegroundWindow() DMFore = "Dispatch-Mate" in win32gui.GetWindowText(fore) while not DMFore: top = Tk() L1 = Label( top, text="Please maximize DispatchMate and the PB in the left monitor") L1.grid(row=0, column=0) def callbackDM(): top.destroy() MyButton4 = Button(top, text="OK", width=10, command=callbackDM) MyButton4.grid(row=1, column=0) popUp(top, w=350, h=50, widget=MyButton4) click(50, 350) fore = win32gui.GetForegroundWindow() DMFore = "Dispatch-Mate" in win32gui.GetWindowText(fore) # # moveTo(2000, 550) # def windowEnumerationHandler(hwnd, top_windows): # top_windows.append((hwnd, win32gui.GetWindowText(hwnd))) # # # results = [] # top_windows = [] # win32gui.EnumWindows(windowEnumerationHandler, top_windows) # for i in top_windows: # if "Dispatch-Mate" in i[1].lower(): # # win32gui.ShowWindow(i[0],5) # win32gui.SetForegroundWindow(i[0]) # break for x in dialogs: if handleprops.classname(x) == "WinDevObject": winChildren = handleprops.children(x) topWindow = x break # description = "" # weight = "" # pieces = "" # terminal = "" # containerNumber = "" # bond = "" # PB = "" # sleep(5) # topWindowWrap = app.window(handle=topWindow) # topWindowWrap.MoveWindow(0,0,1920,1080) # topWindowWrap.Maximize() for x in winChildren: # print(handleprops.text(x)) # if handleprops.classname(x)=="ListBox": # # for y in handleprops.children(x): # # print(handleprops.text(x)) # topWindowWrap = app.window(handle=topWindow) # boxWrap = topWindowWrap.child_window(handle=x).wrapper_object() # if handleprops.text(x)=="Description": # print("desc " + str(handleprops.rectangle(x))) # if "CUT - 7/13" in handleprops.text(x): # print(handleprops.rectangle(x)) # if handleprops.classname(x)=="ComboBox": if handleprops.rectangle(x) == RECT(232, 917, 443, 939): topWindowWrap = app.window(handle=topWindow) boxWrap = topWindowWrap.child_window(handle=x).wrapper_object() # print(boxWrap.texts()) # print(boxWrap.selected_index()) # print(len(boxWrap.children())) # print(boxWrap.get_properties()['texts']) # for y in boxWrap.texts(): # if y !="": # print(boxWrap.ItemData(y)) num = boxWrap.ItemData(boxWrap.texts()[1]) if num < 6: container.size = "20" else: container.size = "40" # else: # container.size = "getInput" # if boxWrap.texts()[1]==r"\x0c": # container.size = '40' # elif boxWrap.texts()[1]==r"\n": # container.size = '40' # elif boxWrap.texts()[1]==r"\x04": # container.size = '20' # elif boxWrap.texts()[1]==r"\x03": # container.size = '20' # elif boxWrap.texts()[1]==r"\x0b": # container.size = '40' # # elif boxWrap.texts()[1]==r"\r": # # container.size = '45' # elif boxWrap.texts()[1]==r"\x07": # container.size = '40' # # elif handleprops.rectangle(x)==RECT(197, 342, 256, 360): # elif handleprops.rectangle(x)==RECT(2090, 146, 2219, 168): # weight = x # # elif handleprops.rectangle(x)==RECT(512, 342, 569, 360): # elif handleprops.rectangle(x)==RECT(2089, 233, 2191, 255): # pieces = x # elif handleprops.rectangle(x)==RECT(625, 342, 722, 360): # containerNumber = x # elif handleprops.rectangle(x)==RECT(14, 295, 73, 313): # terminal = x # elif handleprops.rectangle(x)==RECT(1645, 136, 1818, 171): # bond = x # elif handleprops.rectangle(x)==RECT(182, 991, 250, 1015): # PB = x elif handleprops.rectangle(x) == rects[0]: container.description = handleprops.text(x) # elif handleprops.rectangle(x)==RECT(197, 342, 256, 360): elif handleprops.rectangle(x) == rects[1]: container.weight = handleprops.text(x) # elif handleprops.rectangle(x)==RECT(512, 342, 569, 360): elif handleprops.rectangle(x) == rects[2]: container.pieces = handleprops.text(x) elif handleprops.rectangle(x) == rects[3]: container.containerNumber = handleprops.text(x) elif handleprops.rectangle(x) == RECT(282, 295, 341, 313): container.terminal = handleprops.text(x) # elif handleprops.rectangle(x)==RECT(1645, 136, 1818, 171): # container.bond = handleprops.text(x) elif handleprops.rectangle(x) == RECT(182, 991, 250, 1015): container.PB = handleprops.text(x) elif handleprops.rectangle(x) == RECT(554, 295, 613, 313): container.customer = handleprops.text(x) elif handleprops.rectangle(x) == RECT(14, 891, 231, 985): container.extraText = handleprops.text(x) elif handleprops.rectangle(x) == RECT(14, 128, 265, 146): container.shipper = handleprops.text(x) elif handleprops.rectangle(x) == RECT(14, 176, 265, 194): container.shipperAdd1 = handleprops.text(x) elif handleprops.rectangle(x) == RECT(14, 224, 265, 242): container.shipperCity = handleprops.text(x) elif handleprops.rectangle(x) == RECT(183, 248, 227, 266): if "CDA" in handleprops.text(x): container.shipperCountry = "CA" elif "USA" in handleprops.text(x): container.shipperCountry = "US" else: container.shipperCountry = handleprops.text(x) elif handleprops.rectangle(x) == RECT(14, 248, 54, 266): container.shipperStateProv = handleprops.text(x) elif handleprops.rectangle(x) == RECT(55, 248, 182, 266): container.shipperZipPost = handleprops.text(x) elif handleprops.rectangle(x) == RECT(282, 128, 533, 146): container.consignee = handleprops.text(x) elif handleprops.rectangle(x) == RECT(282, 176, 533, 194): container.consigneeAdd1 = handleprops.text(x) elif handleprops.rectangle(x) == RECT(282, 224, 533, 242): container.consigneeCity = handleprops.text(x) elif handleprops.rectangle(x) == RECT(452, 248, 496, 266): if "CDA" in handleprops.text(x): container.consigneeCountry = "CA" elif "USA" in handleprops.text(x): container.consigneeCountry = "US" else: container.consigneeCountry = handleprops.text(x) elif handleprops.rectangle(x) == RECT(282, 248, 323, 266): container.consigneeStateProv = handleprops.text(x) elif handleprops.rectangle(x) == RECT(324, 248, 451, 266): container.consigneeZipPost = handleprops.text(x) # Pb 362000 is used for widths # if handleprops.text(x)=="MAEU 463991 2": # print("desc") # print(handleprops.rectangle(x)) # elif handleprops.text(x)=="7,660.00": # print("we") # print(handleprops.rectangle(x)) # elif handleprops.text(x)=="6": # print("pi") # print(handleprops.rectangle(x)) # elif handleprops.text(x)=="MAEU 411606 4": # print(handleprops.rectangle(x)) # print(container.containerNumber) # exit() container.containerNumber = container.containerNumber.replace(' ', '') if (container.description == "" or container.weight == "" or container.pieces == "" or container.containerNumber == "" or container.terminal == "" or # container.bond == "" or container.PB == ""): top = Tk() L0 = Label( top, text= "Some of the information is missing. Either fill it in below, or ensure \n that your Dispatch-mate is properly formatted and hit \"Try again\". \n To do so, go to PB362000 and double click on the line between \n the boxes that read \"Description\" and \"Weight\"" ) L0.grid(row=0, column=0, columnspan=2) L1 = Label(top, text="Description:") L1.grid(row=1, column=0, sticky=constants.E) E1 = Entry(top, bd=5) E1.grid(row=1, column=1) E1.insert(0, container.description) L2 = Label(top, text="Weight:") L2.grid(row=2, column=0, sticky=constants.E) E2 = Entry(top, bd=5) E2.grid(row=2, column=1) E2.insert(0, container.weight) L3 = Label(top, text="Piece Count:") L3.grid(row=3, column=0, sticky=constants.E) E3 = Entry(top, bd=5) E3.grid(row=3, column=1) E3.insert(0, container.pieces) L4 = Label(top, text="Container Number:") L4.grid(row=4, column=0, sticky=constants.E) E4 = Entry(top, bd=5) E4.grid(row=4, column=1) E4.insert(0, container.containerNumber) L5 = Label(top, text="Consignee:") L5.grid(row=5, column=0, sticky=constants.E) E5 = Entry(top, bd=5) E5.grid(row=5, column=1) E5.insert(0, container.terminal) # L6 = Label(top, text="Bond #:") # L6.grid(row=6, column=0, sticky=constants.E) # E6 = Entry(top, bd = 5) # E6.grid(row=6, column=1) # E6.insert(0, container.bond) L7 = Label(top, text="PB #:") L7.grid(row=6, column=0, sticky=constants.E) E7 = Entry(top, bd=5) E7.grid(row=6, column=1) E7.insert(0, container.PB) def callbackGoAhead(container): container.description = E1.get() container.weight = E2.get() container.pieces = E3.get() container.containerNumber = E4.get() container.terminal = E5.get() # container.bond = E6.get() container.PB = E7.get() top.destroy() def checkStuff(): app = Application(backend="win32").connect( path=r"C:\DM54_W16\DM54_W16.exe") winChildren = "" dialogs = app.windows() for x in dialogs: if handleprops.classname(x) == "WinDevObject": winChildren = handleprops.children(x) topWindow = x break for x in winChildren: if handleprops.text(x) == E1.get(): rects[0] = handleprops.rectangle(x) if handleprops.text(x).replace(",", "") == E2.get(): rects[1] = handleprops.rectangle(x) if handleprops.text(x) == E3.get(): rects[2] = handleprops.rectangle(x) if handleprops.text(x) == E4.get(): rects[3] = handleprops.rectangle(x) writeRects(rects) # top.lift() # top.attributes('-topmost',True) # top.after_idle(top.attributes,'-topmost',False) # widget = E1 # moveTo(widget.winfo_rootx()+widget.winfo_width()/2, widget.winfo_rooty()+5+widget.winfo_height()/2) def callbackDetect(): top.after_idle(checkStuff) def callbackTryAgain(container): top.destroy() setupDM(container) MyButton4 = Button(top, text="Use these values", width=17, command=lambda: callbackGoAhead(container)) MyButton4.grid(row=8, column=1) MyButton5 = Button(top, text="Try again", width=10, command=lambda: callbackTryAgain(container)) MyButton5.grid(row=8, column=0) MyButton5 = Button( top, text= "Set box locations: \n (copy description, weight, piece and cont# \n into the boxes above then hit this button)", width=10, command=callbackDetect) MyButton5.grid(row=9, column=0, columnspan=2, sticky=constants.W + constants.E) popUp(top, w=380, h=340, widget=E1)
def setupDM(folderPath, drivers): # app = Application(backend="win32").connect(path = r"C:\DM54_W16\DM54_W16.exe") # # # top_windows = [] # # EnumWindows(windowEnumerationHandler, top_windows) # # for i in top_windows: # # if 'Dispatch-Mate' in i[1]: # # SetWindowPos(i[0], None, 0, 0, 1920, 1080, SWP_SHOWWINDOW) # # SetForegroundWindow(i[0]) # # # winChildren = "" # # dialogs = app.windows() # # for x in dialogs: # if handleprops.classname(x) == "WinDevObject": # winChildren = handleprops.children(x) # topWindow = x # break clickTuple = False click(50, 350) fore = win32gui.GetForegroundWindow() DMFore = "Dispatch-Mate" in win32gui.GetWindowText(fore) while not DMFore: top = Tk() L1 = Label(top, text="Please maximize DispatchMate and the PB in the left monitor") L1.grid(row=0, column=0) def callbackDM(): top.destroy() MyButton4 = Button(top, text="OK", width=10, command=callbackDM) MyButton4.grid(row=1, column=0) popUp(top, w=350, h=50, widget = MyButton4) click(50, 350) fore = win32gui.GetForegroundWindow() DMFore = "Dispatch-Mate" in win32gui.GetWindowText(fore) # i=0 for driver in drivers: # if i>0: click(327, 33) sleep(3) click(399, 281) if driver.PARS[-1]=="A" or driver.PARS[-1]=="B" or driver.PARS[-1]=="C": typewrite(driver.PARS[-7:-1]) else: typewrite(driver.PARS[-6:]) press("enter") sleep(3) click(1857, 100) sleep(0.5) click(569, 900) month = str(pickupDate.month) if len(month)<2: month = "0" + month typewrite(month) day = str(pickupDate.day) if len(day)<2: day = "0" + day typewrite(day) typewrite(str(pickupDate.year)) click(569, 926) month = str(pickupDate.month) if len(month)<2: month = "0" + month typewrite(month) day = str(pickupDate.day) if len(day)<2: day = "0" + day typewrite(day) typewrite(str(pickupDate.year)) click(695, 100) click(1542, 730) typewrite(str(driver.driver)) press('enter') if str(driver.driver)[:3]!="801": click(1558,679) typewrite(driver.name) press('enter') sleep(0.5) thru = False click(189, 854) hotkey('ctrl', 'a') hotkey('ctrl', 'c') clipTk=Tk() if "THRUWAY" in clipTk.clipboard_get(): thru = True typewrite("TRUCK") press('tab') typewrite("0.55") press('tab') press('delete') press('tab') miles = "490" if str(driver.city)=="PACKER": miles = "507" if str(driver.city)=="NYCT": miles = "500" typewrite(miles) click(189, 890) hotkey('ctrl', 'a') hotkey('ctrl', 'c') if "THRUWAY" in clipTk.clipboard_get(): thru = True click(189, 872) hotkey('ctrl', 'a') hotkey('ctrl', 'c') if "THRUWAY" in clipTk.clipboard_get(): thru = True if thru: typewrite("COMPANY DR THRUWAY") press('tab') typewrite("1.00") press('tab') press('delete') press('tab') if str(driver.city)=="PACKER": typewrite("81.4") else: typewrite("31.9") else: press('delete') press('tab') press('delete') press('tab') press('delete') press('tab') press('delete') click(189, 890) hotkey('ctrl', 'a') hotkey('ctrl', 'c') if "THRUWAY" in clipTk.clipboard_get(): thru = True clipTk.destroy() if thru: press('delete') press('tab') press('delete') press('tab') press('delete') press('tab') press('delete') if GetKeyState(145) < 0: exit() sleep(2) click(1857, 120) click(1857, 120) sleep(3) click(1845, 200, button="right") sleep(1) click(1826, 312) sleep(0.3) # click(1600, 316) # # sleep(7) click(1600, 361) sleep(0.3) click(1772, 160) # sleep(5) # sleep(5) done=False while not done: try: if os.path.isfile(r"C:\Program Files\Microsoft Office 15\root\office15\outlook.exe"): app = Application(backend="win32").connect(path = r"C:\Program Files\Microsoft Office 15\root\office15\outlook.exe") elif os.path.isfile(r"C:\Program Files (x86)\Microsoft Office\root\Office16\OUTLOOK.EXE"): app = Application(backend="win32").connect(path = r"C:\Program Files (x86)\Microsoft Office\root\Office16\OUTLOOK.EXE") elif os.path.isfile(r"C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE"): app = Application(backend="win32").connect(path = r"C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE") # elif os.path.isfile(r"C:\Program Files\WindowsApps\Microsoft.Office.Desktop.Outlook_16040.10827.20138.0_x86__8wekyb3d8bbwe\Office16\outlook.exe"): # app = Application(backend="win32").connect(path = r"C:\Program Files\WindowsApps\Microsoft.Office.Desktop.Outlook_16040.10827.20138.0_x86__8wekyb3d8bbwe\Office16\outlook.exe") else: directoryPath = "C:\Program Files\WindowsApps\\" if os.path.isdir("C:\Program Files\WindowsApps\\"): contents = os.listdir("C:\Program Files\WindowsApps\\") outLookFolders=[] for folder in contents: if os.path.isdir("C:\Program Files\WindowsApps\\"+folder): if "outlook" in folder.lower(): outLookFolders.append(folder) outlookPath = "" for folder in outLookFolders: contents = os.listdir("C:\Program Files\WindowsApps\\"+folder) for officeFolder in contents: if os.path.isdir(directoryPath+folder+"\\"+officeFolder): if "office" in officeFolder.lower(): contentsInner = os.listdir(directoryPath+folder+"\\"+officeFolder) for outlookProgram in contentsInner: if outlookProgram.lower()=="outlook.exe": outlookPath=directoryPath+folder+"\\"+officeFolder+"\\"+outlookProgram if os.path.isfile(outlookPath): app = Application(backend="win32").connect(path = outlookPath) else: popUpOK("Could not find Outlook in \"C:\Program Files\Microsoft Office 15\root\office15\outlook.exe\" \n or \"C:\Program Files (x86)\Microsoft Office\root\Office16\OUTLOOK.EXE\" \n or \"C:\Program Files (x86)\Microsoft Office\Office14\" \n or the \"C:\Program Files\WindowsApps\\\" folder") exit() done=True except: pass # top_windows = [] # EnumWindows(windowEnumerationHandler, top_windows) # for i in top_windows: # if 'Dispatch-Mate' in i[1]: # SetWindowPos(i[0], None, 0, 0, 1920, 1080, SWP_SHOWWINDOW) # SetForegroundWindow(i[0]) winChildren = "" done = False while not done: dialogs = app.windows() topWindow = None for x in dialogs: if isinstance(handleprops.text(x), str) and not handleprops.text(x)==None: try: if "Carrier Confirmation" in handleprops.text(x): winChildren = handleprops.children(x) topWindow = x break except: pass send = "" if topWindow==None: continue topWindowWrap = app.window(handle=topWindow) for x in winChildren: # print(handleprops.text(x) + " " + handleprops.classname(x)) if handleprops.text(x)=="&Send": send = x done = True # if handleprops.text(x)=="Fro&m": # buttonWrap = topWindowWrap.child_window(handle=x).wrapper_object() # buttonWrap.click() # # # if not clickTuple: # moveTo(114, 221) # # while not GetKeyState(145)<0: # True # # clickTuple = position() # # # else: # click(clickTuple) if done==True: buttonWrap = topWindowWrap.child_window(handle=send).wrapper_object() buttonWrap.click() # winChildren = handleprops.children(topWindow) # # for x in winChildren: # # print(handleprops.text(x) + " " + handleprops.classname(x)) # if handleprops.classname(x)=="NetUIHWND": # topWindowWrap = app.window(handle=topWindow) # netWrap = topWindowWrap.child_window(handle=x).wrapper_object() # print(netWrap.Texts()) # # for y in handleprops.children(x): # print(handleprops.text(y)) # # app.top_window().window(title="From", control_type="Button").print_control_identifiers() # if not clickTuple: # # moveTo(113, 167) # # while not GetKeyState(13)<0: # True # # clickTuple = position() # # else: # sleep(5) # click((113, 167)) # # click(clickTuple) sleep(4)