def connectToHndlFetchPossibleUrl(self, win_hndl):
        app = Application(backend='uia')

        try:
            app.connect(handle=win_hndl)
            dlgs = app.windows(
            )  # for some reason when we fetch the list of opens windows for a given app, urls seems to be fetched 'always' correctly, when we use app.top_window() sometimes url element is empty
            # when we handle list of windows; then top window is always first on the list; and during checking url validation whe always stop after getting the first url
            # hacky, but seems to work now
        except RuntimeError:
            print('Couldnt connect to last application :(')
            fetched_url = ''
        else:
            potential_urls = self.__findPotentialUrlsFromBrowser(dlgs)
            fetched_url = self.__findUrlInStringList(potential_urls)

            # XTODO: Think of a way to fix this brutal way; possibly dlg.wait() could be useful, need to play with it's
            # parameters, so this wait wouldnt fail
            # doesnt seem to necessary anymore
            # if fetched_url == '':
            #     time.sleep(1)
            #     potential_urls = self.__findPotentialUrlsFromBrowser(dlgs)
            #     fetched_url = self.__findUrlInStringList(potential_urls)

        return fetched_url
Exemple #2
0
def init_weixin():
    app = Application().start(
        r"C:\Program Files (x86)\Tencent\WeChat\WeChat.exe")
    if not app.windows():
        app = Application().connect(
            path=r"C:\Program Files (x86)\Tencent\WeChat\WeChat.exe")
    dlg = app.window(title=u"微信", class_name="WeChatMainWndForPC")
    dlg.move_window(0, 0)
    ie_dlg = app.window(title=u"微信", class_name="CefWebViewWnd")
    ie_dlg.move_window(0, 0)
    ie_dlg.set_focus()
    dlg.set_focus()
    print(ie_dlg.print_control_identifiers())
    return dlg
Exemple #3
0
def ff_urls():
    urls = []
    try:
        firefox = Application(backend="uia").connect(title_re='.*Firefox.*')
    except:
        print(
            r"<font color='Red'>[music-dl] ERROR: Firefox is not running</font>"
        )
        return urls
    wd = firefox.windows()[0]
    tabs = wd.children()
    for tab in tabs:
        try:
            s = tab.children()[0].children()[0]
            url = s.legacy_properties()["Value"]
            urls.append(url)
        except:
            pass
    return urls
Exemple #4
0
        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)
    # ipo_grid_handle = 0x8105a
    # print_time(op.SendMessageW(ipo_grid_handle, WM_COMMAND, 57634, ipo_grid_id[-1]))
    # print_time(pyperclip.paste())

    main_wnd = Desktop()["股票交易系统"]
    app = Application().connect(handle=main_wnd.handle)
    pup = unity(main_wnd.handle)
    # test is_client_dead
    while True:
        print_time(pup.is_client_dead())
        time.sleep(3)

    for id in id_members:
        print_time("find id=%x" % id)
        # controls = findwindows.find_windows(control_id=id)
        controls = app.windows(control_id=id)
        print_time(controls)
        for c in controls:
            c.print_time_control_identifiers()
    pup.buy("000001", "9.33", "1000")
    exit(0)
    pup.raffle(True)

    for i in range(1, 100):
        ctrl = main_wnd[str("CVirtualGridCtrl%d" % i)]
        if ctrl.exists():
            print_time("%x" % ctrl.handle)
            print_time(copy_data(ctrl.handle))
        else:
            break
Exemple #6
0
start(self, cmd_line, timeout=app_start_timeout)  # instance method:
connect(self, **kwargs)  # instance method:
app = Application().start(r"c:\path\to\your\application -a -n -y --arguments")

app = Application().connect(process=2341)  #process id
app = Application().connect(handle=0x010f0c)  #handle
app = Application().connect(path=r"c:\windows\system32\notepad.exe")  #path
""" pywinauto.findwindows.find_elements() """
app = Application().connect(title_re=".*Notepad", class_name="Notepad")
""" How to specify a dialog of the application """
dlg = app.Notepad
dlg = app['Notepad']
dlg = app.top_window()
findwindows.find_windows()
dlg = app.window(title_re="Page Setup", class_name="#32770")
dialogs = app.windows()  #this will return a list of all the visible, enabled,
# top level windows of the application
app.window(handle=win)  #we can use the handle like this once we have it
app.window(title_re=".*Part of Title.*")  # if title of the dialog is very long
"""How to specify a control on a dialog """
app.dlg.control
app['dlg']['control']
"""Once a set of identifiers has been created for all controls in the dialog we disambiguate them.
use the WindowSpecification.print_control_identifiers() method"""
app.YourDialog.print_control_identifiers()
"""How to Access the System Tray"""
import pywinauto.application
app = pywinauto.application.Application().connect(path="explorer")
systray_icons = app.ShellTrayWnd.NotificationAreaToolbar

ClickSystemTrayIcon(button)
Exemple #7
0
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)
Exemple #8
0
    0x00ff00: 'green',
    0x00ffff: 'yellow',
    0xff0000: 'blue',  # blue color (RGB = 0x0000FF).
    0xff00ff:
    'pink',  #应该是 Magenta 洋红 On computer screens, it is made by mixing equal amounts of blue and red
    0xffff00: 'cyan',  #Cyan is a greenish-blue color. 青色
    0xffffff: 'white',
}
glc = list(gColour.keys())

hs = [i[0] for i in Win.getAllWindows() if gsTitle in i[1]]

if len(hs) != 1: raise EnvironmentError('sould only one npp', hs)

app = app.Connect(handle=hs[0])
ws = app.windows()
for i in ws:
    txt = i.window_text()
    if gsTitle in txt: wm = i
    #'剪贴板历史记录'
    if u'\u526a\u8d34\u677f\u5386\u53f2\u8bb0\u5f55' == txt:
        wc = i
        break
    if u'Clipboard History' in txt:
        wc = i
es = wc.element_info.children()

for i in es:
    if i.class_name == u'ListBox':
        elb = i
lb = wc.backend.generic_wrapper_class(elb)
Exemple #9
0
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)