def test_rectangle(self):
        """Make sure rectangle() function works"""
        dlgrect = rectangle(self.dlghandle)
        self.assertEquals(True, dlgrect.left < dlgrect.right)
        self.assertEquals(True, dlgrect.top < dlgrect.bottom)

        editrect = rectangle(self.edit_handle)
        self.assertEquals(True, editrect.left < editrect.right)
        self.assertEquals(True, editrect.top < editrect.bottom)
예제 #2
0
    def test_rectangle(self):
        """Make sure rectangle() function works"""
        dlgrect = rectangle(self.dlghandle)
        self.assertEqual(True, dlgrect.left < dlgrect.right)
        self.assertEqual(True, dlgrect.top < dlgrect.bottom)

        editrect = rectangle(self.edit_handle)
        self.assertEqual(True, editrect.left < editrect.right)
        self.assertEqual(True, editrect.top < editrect.bottom)
예제 #3
0
    def test_rectangle(self):
        "Make sure the friendly class is set correctly"
        dlgrect = rectangle(self.dlghandle)
        self.assertEquals(True, dlgrect.left < dlgrect.right)
        self.assertEquals(True, dlgrect.top < dlgrect.bottom)

        editrect = rectangle(self.edit_handle)
        self.assertEquals(True, editrect.left < editrect.right)
        self.assertEquals(True, editrect.top < editrect.bottom)
예제 #4
0
    def test_rectangle(self):
        "Make sure the friendly class is set correctly"
        dlgrect = rectangle(self.dlghandle)
        self.assertEquals(True, dlgrect.left < dlgrect.right)
        self.assertEquals(True, dlgrect.top < dlgrect.bottom)

        editrect = rectangle(self.edit_handle)
        self.assertEquals(True, editrect.left < editrect.right)
        self.assertEquals(True, editrect.top < editrect.bottom)
    def test_clientrect(self):
        """Make sure clientrect() function works"""
        self.assertEquals(0, clientrect(self.dlghandle).left)
        self.assertEquals(0, clientrect(self.edit_handle).left)

        self.assertEquals(0, clientrect(self.dlghandle).top)
        self.assertEquals(0, clientrect(self.edit_handle).top)

        self.assertEquals(True,
            rectangle(self.dlghandle).right > clientrect(self.dlghandle).right)
        self.assertEquals(True,
            rectangle(self.edit_handle).right > clientrect(self.edit_handle).right)

        self.assertEquals(True,
            rectangle(self.dlghandle).bottom > clientrect(self.dlghandle).bottom)
        self.assertEquals(True,
            rectangle(self.edit_handle).bottom > clientrect(self.edit_handle).bottom)
예제 #6
0
    def test_clientrect(self):
        "Make sure the friendly class is set correctly"
        self.assertEquals(0, clientrect(self.dlghandle).left)
        self.assertEquals(0, clientrect(self.edit_handle).left)

        self.assertEquals(0, clientrect(self.dlghandle).top)
        self.assertEquals(0, clientrect(self.edit_handle).top)

        self.assertEquals(True,
            rectangle(self.dlghandle).right > clientrect(self.dlghandle).right)
        self.assertEquals(True,
            rectangle(self.edit_handle).right > clientrect(self.edit_handle).right)

        self.assertEquals(True,
            rectangle(self.dlghandle).bottom > clientrect(self.dlghandle).bottom)
        self.assertEquals(True,
            rectangle(self.edit_handle).bottom > clientrect(self.edit_handle).bottom)
예제 #7
0
    def test_clientrect(self):
        """Make sure clientrect() function works"""
        self.assertEqual(0, clientrect(self.dlghandle).left)
        self.assertEqual(0, clientrect(self.edit_handle).left)

        self.assertEqual(0, clientrect(self.dlghandle).top)
        self.assertEqual(0, clientrect(self.edit_handle).top)

        self.assertEqual(True,
            rectangle(self.dlghandle).right > clientrect(self.dlghandle).right)
        self.assertEqual(True,
            rectangle(self.edit_handle).right > clientrect(self.edit_handle).right)

        self.assertEqual(True,
            rectangle(self.dlghandle).bottom > clientrect(self.dlghandle).bottom)
        self.assertEqual(True,
            rectangle(self.edit_handle).bottom > clientrect(self.edit_handle).bottom)
예제 #8
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)
예제 #9
0
    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)
예제 #10
0
    def test_clientrect(self):
        "Make sure the friendly class is set correctly"
        self.assertEquals(0, clientrect(self.dlghandle).left)
        self.assertEquals(0, clientrect(self.edit_handle).left)

        self.assertEquals(0, clientrect(self.dlghandle).top)
        self.assertEquals(0, clientrect(self.edit_handle).top)

        self.assertEquals(
            True,
            rectangle(self.dlghandle).right > clientrect(self.dlghandle).right)
        self.assertEquals(
            True,
            rectangle(self.edit_handle).right > clientrect(
                self.edit_handle).right)

        self.assertEquals(
            True,
            rectangle(self.dlghandle).bottom > clientrect(
                self.dlghandle).bottom)
        self.assertEquals(
            True,
            rectangle(self.edit_handle).bottom > clientrect(
                self.edit_handle).bottom)
예제 #11
0
    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)
예제 #12
0
    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
예제 #13
0
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")
예제 #14
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)