Exemple #1
0
def install_qttabbar():
    print('Installing Qttabbar.....')
    wget.download(
        'http://qttabbar.wdfiles.com/local--files/qttabbar1/QTTabBar_1043.zip',
        rf"{path}\software\QTTabBar.zip")
    os.system(
        rf"{path}\tools\7za.exe x {path}\software\QTTabBar.zip -o{path}\software"
    )
    os.system(rf"{path}\software\QTTabBar.exe /qi")
    qttabbar = False
    for win in Desktop(backend="uia").windows():
        if win.class_name() == "CabinetWClass":
            break
    else:
        qttabbar = True
        Application(backend="uia").start('explorer.exe')
        win = Desktop(backend="uia").window(class_name="CabinetWClass")
    win.set_focus()
    keyboard.send_keys("{VK_MENU}")
    keyboard.send_keys("{V}")
    time.sleep(0.5)
    keyboard.send_keys("{Y}")
    keyboard.send_keys("{DOWN}")
    keyboard.send_keys("{DOWN}")
    keyboard.send_keys("{DOWN}")
    keyboard.send_keys("{ENTER}")
    if qttabbar:
        win.close()
    os.system('cls')
Exemple #2
0
def mysql_installation():
    # Loading the app exe file from the directory.

    '''

    pywinauto dialogue select best name for the dialgoue combination. more details can be found here.

    https://pywinauto.readthedocs.io/en/latest/getting_started.html#attribute-resolution-magic
    https://pywinauto.readthedocs.io/en/latest/wait_long_operations.html

    :return:
    '''

    app = Application(backend="uia").start("setups/wampserver.exe")

    # selecting  the language dialogue box.
    Wizard = Desktop(backend='uia').Select_Setup_Language
    Wizard.OK.click_input()
    # app.InstallDialog.IAgreeRadioButton.wait('ready', timeout=30).click_input()

    Wizard2 = Desktop(backend='uia').Setup_Wampserver64
    Wizard2.i_accept_the_agreement.click_input()
    Wizard2.NextButton.click_input()
    Wizard2.NextButton.click_input()
    Wizard2.NextButton.click_input()
    Wizard2.Install.click_input()

    # waiting for open dialogue to be closed
    Wizard2.wait_not('visible')

    # After installation, start the application from the windows installed directory
    start_wamp()
    time.sleep(5)
    # setup the database. This batch file created database in the db MySQL and improt all the sql file data into it.
    os.startfile(os.getcwd() + '/setups/database.bat')
Exemple #3
0
 def calDemo(self):
     app = Application(backend="uia").start('calc.exe')
     dlg = Desktop(backend="uia").Calculator
     dlg.type_keys('2*3=')
     dlg.print_control_identifiers()
     dlg.minimize()
     Desktop(backend="uia").window(title='Calculator',
                                   visible_only=False).restore()
Exemple #4
0
 def start_from_tray(self, tray_icon):
     tray_icon.wrapper_object().click_input()
     tray_icon_menu = Desktop(backend="uia").window(
         **self.configs['TaskBar']['teacher_menu']['id'])
     tray_icon_menu.wait('visible', timeout=10)
     tray_icon_menu.window(**self.configs['TaskBar']['teacher_menu']
                           ['display_win']).wrapper_object().click_input()
     main_win = Desktop(backend="uia").window(
         **self.configs['teachermain']['main']['id'])
     main_win.exists(timeout=5)
Exemple #5
0
def delete_study(dialog, study):

    dialog.child_window(title="Workspace",
                        control_type="MenuItem").click_input()
    Desktop(backend="uia").Menu.child_window(
        title="Close Study", control_type="MenuItem").click_input()
    dialog.window(title=study, found_index=0).right_click_input()
    Desktop(backend="uia").Menu.child_window(
        title="Delete Study", control_type="MenuItem").click_input()
    dialog.child_window(title="Delete Enter",
                        control_type="Button").click_input()

    return
Exemple #6
0
def handle_dismiss(title, dlgwd):
	# handles the alert that happens in this specific case and dismisses it. Handle is to be tailored to its specific job. TODO: Maybe more functionality
	dlg = Desktop(backend="uia")['%s' %title]
	dlg[dlgwd].set_focus()
	#dlg.restore()
	keyboard.SendKeys("{VK_ESCAPE}")
	print "handle-function finished"
Exemple #7
0
 def click_lesson(self, lesson_name):
     lesson_win = Desktop(backend="uia").window(
         **self.configs['lesson_win']['id'])
     lesson_win.wait('visible', timeout=30)
     lessons = self.get_lesson_list(lesson_win)
     for lesson in lessons.keys():
         #self.logger.debug("Lesson: %s." % lesson)
         if lesson_name == lesson:
             if len(lessons) > 1:  # 单个课程,不需点击
                 lessons[lesson_name].click()
             dialog_confirm = lesson_win.window(
                 **self.configs['lesson_win']['confirm']['id'])
             dialog_confirm.window(
                 **self.configs['lesson_win']['confirm']['ok']).click()
             lesson_win.wait_not('visible', timeout=60)
         elif lesson_name in lesson and '\r\n(上课中...)' in lesson:
             self.logger.debug("%s is working." % lesson_name)
             lesson_win.window(
                 **self.configs['lesson_win']['exit']).click()  # 关闭
         elif len(lessons) == 1:  # 单个课程,且课程名称不匹配情况
             dialog_confirm = lesson_win.window(
                 **self.configs['lesson_win']['confirm']['id'])
             dialog_confirm.window(
                 **self.configs['lesson_win']['confirm']['ng']).click()
             lesson_win.wait_not('visible', timeout=60)
         else:
             self.logger.debug("%s in config doesnot exists." % lesson_name)
    def __init__(self, app: QApplication, origin_draw_position: QPoint):
        """
        Locate a desktop window rectangle with the mouse cursor

        :param QApplication app: App to install event filter on
        :param QPoint origin_draw_position: Position of the line, indicating the tracked cursor, is drawn from
        """
        super(FindDesktopWindowInteractive, self).__init__()
        self.app = app

        self.tracking_timer = QTimer()
        self.tracking_timer.setInterval(self.tracking_rate)
        self.tracking_timer.timeout.connect(self._track_cursor)

        self.paint_timer = QTimer()
        self.paint_timer.setInterval(self.painting_rate)
        self.paint_timer.timeout.connect(self._trigger_paint)

        self.cursor = QCursor()
        self.pywin_desktop = Desktop()

        self.highlight_rect = QRect()

        self.origin_draw_pos = origin_draw_position

        # -- Transparent widget across the desktop to draw on --
        self.desk_draw_widget = DesktopDrawWidget(app.desktop())
        self.desk_draw_widget.paintEvent = self._paint_event_override
Exemple #9
0
    def foreGroundDiscord(
            self):  # it will make discord window top of all other windows

        windows = Desktop(backend="uia").windows()

        title = ""
        for w in windows:
            if "Discord" in str(w.window_text):
                title = str(w.window_text).split("'")[1]
                break

        app = None
        try:
            app = Application().connect(title_re=title)

        except (__import__("re").error,
                pywinauto.findwindows.ElementAmbiguousError):
            raise GuiDoesNotExists
            return

        hwin = app.top_window()

        hwin.set_focus()

        sleep(0.9)
Exemple #10
0
 def press_enter():
   #press enter instead of clicking on the element because click() blocks
   spec_dlg = Desktop(backend="uia")["Login"]
   spec_dlg.set_focus()
   #restore is a cheap hack to select the window
   spec_dlg.restore()
   keyboard.SendKeys('{ENTER}')
Exemple #11
0
def openDevelopmentMode():
    runProgram('ms-settings:developers')
    settings = Desktop(backend="uia")["Settings"]
    btn = settings['For developersGroupBox'].RadioButton3
    btn.click()
    settings['Use developer featuresDialog'].Yes.click()
    settings.close()
Exemple #12
0
def close_aoe():
    dlg = Desktop(backend="win32").window(title_re=game_title)
    left, top, right, bot = getrect(dlg.handle)
    focus_and_click(game_title, right - left - 20, 10)
    time.sleep(1)
    focus_and_click(game_title, (750 / 1680) * (right - left),
                    (580 / 1050) * (bot - top - 20))
	def makeWorkingAppInstance(self, commandList):
		# helper pipe to flush popen
		self.DEVNULL = open(os.devnull, 'w')
		# get the hwnds of windows now
		desktopInstance = Desktop(backend="win32")
		hwnds = []
		for window in desktopInstance.windows():
			# get the hwnd as an int
			hwnds.append(int(window.handle))
		# start the instance now
		# sill be used many times throughout this function
		appInstance = Application(backend="win32")
		# first things first, lets try to create one from scratch
		self.pid = subprocess.Popen(commandList, stdout=self.DEVNULL).pid
		appInstance.connect(process=self.pid)
		if len(appInstance.windows()) != 0:
			# the app we created has some windows, we are done
			self.usedExisting = True
			self.mainWindow = appInstance.top_window()
			self.mainWindow.wait("enabled")
			# It worked
			return True
		else:
			# maybe use best_match=commandList[0].split(".")[0]
			# we have to search through existing windows
			# TODO no new windows appear for some reason
			for window in desktopInstance.windows():
				if int(window.handle) not in hwnds:
					self.usedExisting = False
					self.mainWindow = window
					# break out of function
					return True
			# if it reached here, nothing has been found
			return False
Exemple #14
0
def __job__():
     # Gets all open windows, runs through the list of excluded programs and sorts by visibility
     windows = Desktop(backend="uia").windows()
     windowList = ([w.window_text() for w in windows])
     ExcludeFromList.__remove__(windowList)
     Visibility.__notMinimized__(windowList)

     # Checks for ammount of monitors

     monitorLen = len(monitors)

     # Checks if a new window has been opened or a window has been closed
     if len(windowList) == numWindow and len(monitors) == monitorLen:
          #null = 'null'
          print('Number of window stays the same')
     else:
          numWindow = len(windowList) # Updates the number of open windows
          print("List length: " + str(len(windowList)))
          # Additional checks when running in IDE
          for program in windowList:
               Window = gw.getWindowsWithTitle(program)[0]
               print(Window)
          windowList = tuple(windowList)

          # Arranges windows depending on number of connected monitors
          count = 0
          while count <= 3:
               if monitorLen == 1:
                    ResizeSingle.__resize__(windowList)
                    count += 1
               if monitorLen == 2:
                    ResizeDual.__resize__(windowList)
                    count += 1
def stopTestApp():
    print('Stop TestApp VPN...')
    
    dlg = Desktop(backend="uia").HydraTestAppShell
    # C:\Program Files (x86)\Hydra Test Application>taskkill /im "TestApp.exe" /f
    dlg.child_window(auto_id='DisconnectVpnBtn', control_type="Button").click()
    time.sleep(10)
Exemple #16
0
 def add_file(self, file_path):
     """添加文件"""
     app = Desktop()
     dialog = app['打开']
     time.sleep(2)
     dialog["Edit"].type_keys(file_path)
     dialog["Button"].click()
Exemple #17
0
def click_splitbutton(dialog, button):

    split_buttons = {"SAX LV Endocardial Contour": 6,
                     "SAX LV Open Endocardial Contour": 6,
                     "SAX LV Epicardial Contour": 7,
                     "SAX LV Open Epicardial Contour": 7,
                     "SAX Papillary Muscle Contour": 8,
                     "SAX LV Exclude Area Contour": 8,
                     "SAX Reference Point": 9,
                     "SAX Inferior Reference Point": 9,
                     "Line Contour": 10,
                     "Freehand Contour": 10,
                     "Curved Length Measurement": 10,
                     "SAX RV Endocardial Contour": 11,
                     "SAX RV Epicardial Contour": 11,
                     "SAX RV Papillary muscle Contour": 12,
                     "SAX RV Exclude Area Contour": 12}

    if dialog.child_window(title=button).exists() is False:
        for filtered_button in [k for k, v in split_buttons.items()
                                if v == split_buttons[button]]:
            if dialog.child_window(title=filtered_button).exists() is True:
                dialog.child_window(title=filtered_button).right_click_input()
                Desktop(backend="uia").Menu.child_window(title=button, control_type="MenuItem").click_input()

    else:
        dialog.child_window(title=button).click_input()
        dialog.progressbar.exists()

    return
Exemple #18
0
def test1001_anonymize_study(dialog, study, anon_name, filename):

    if dialog.child_window(title="Toolbar", control_type="ToolBar").\
            child_window(title="Patient List", control_type="Button").exists() is True:
        dialog.child_window(title="Toolbar",
                            control_type="ToolBar").child_window(
                                title="Patient List",
                                control_type="Button").click_input()

    dialog.Edit.set_text(study)
    dialog.window(title=study).right_click_input()
    Desktop(backend="uia").Menu.child_window(
        title="Anonymize Study", control_type="MenuItem").click_input()
    dialog.child_window(title="Anonymize",
                        control_type="Window").Edit.set_text(anon_name)
    dialog.child_window(title="Anonymize",
                        control_type="Window").OKEnter.click_input()

    start = time.time()
    dialog.child_window(title="Import Study done", control_type="StatusBar").wait('visible', 10000) or \
        dialog.child_window(title="Load image previews done", control_type="StatusBar").wait('visible', 10000)
    end = time.time()

    print "Time to anonymize study: %.2f" % (end - start)
    outputFile.print_timing(1001, end - start, filename)
    return anon_name
Exemple #19
0
def runEdgeDevTools():
    os.system(
        r'C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdgeDevToolsClientBeta.appx'
    )
    install = Desktop(backend="uia")["App Installer"]
    install['Install Microsoft Edge DevTools Client? Install'].click()
    time.sleep(60)
    install.CloseButton.click()
Exemple #20
0
def get_url_from_active_tab():
    # Ищем окно у которого в классе встречается Chrome
    chrome_app = Desktop(backend="uia").window(class_name_re='Chrome')
    # Получаем wrapper_object строки с юрл
    address_bar_wrapper = chrome_app['Google Chrome'].main.Edit.wrapper_object(
    )
    url_from_browser = address_bar_wrapper.legacy_properties()['Value']
    return url_from_browser
Exemple #21
0
def startCalcDialog() -> Application():
    "This method just returns a Calculator dialog"
    app = Application(backend='uia').start('calc.exe')
    # needed since the application spaws additional processes
    # windows = Desktop(backend='uia').windows()
    # for w in windows:
    #     print(w.window_text())
    return Desktop(backend='uia').Calculator
Exemple #22
0
    def pegar_nome(self):
        janelas = Desktop(backend="uia").windows()
        janelas = [w.window_text() for w in janelas]

        for nome in janelas:
            if nome.find('Talisman Online | ') != -1:
                self.nome_do_processo = nome
                break
Exemple #23
0
def click_ml(dialog, ml_button, app):

    machine_butto = {"Detect Endo/Epi Contours Current Phase": 1,
                     "Detect Endo/Epi Contours Current Slice": 1,
                     "Detect Endo/Epi Contours Entire Stack": 1,
                     "Detect Endo/Epi Contours Current Image": 1,
                     "Detect Endo Contours Current Phase": 1,
                     "Detect Endo Contours Current Slice": 1,
                     "Detect Endo Contours Entire Stack": 1,
                     "Detect Epi Contours Current Phase": 1,
                     "Detect Epi Contours Current Slice": 1,
                     "Detect Epi Contours Entire Stack": 1,
                     "Detect RV Contours Current Phase": 2,
                     "Detect RV Contours Current Slice": 2,
                     "Detect RV Contours Entire Stack": 2,
                     "Detect LV/RV Contours at ED/ES Phases": 3,
                     "Detect LV/RV Contours Current Phase": 3,
                     "Detect LV/RV Contours Entire Stack": 3,
                     "Detect LV/RV Contours Current Slice": 3,
                     "Detect LV/RV Contours Current Image": 3,
                     "Detect LV Endo/Epi Contours Current Phase": 4,
                     "Detect LV Endo Contours Current Phase": 4,
                     "Detect LV Endo/Epi Contours Entire Stack": 4,
                     "Detect LV Endo Contours Entire Stack": 4,
                     "Detect RV Contours Current Phase": 5,
                     "Detect RV Contours Entire Stack": 5}

    if dialog.child_window(title=ml_button).exists() is False:
        for filtered_button in [k for k, v in machine_butto.items()
                                if v == machine_butto[ml_button]]:
            # print filtered_button
            if dialog.child_window(title=filtered_button, found_index=0).exists() is True:
                dialog.child_window(title=filtered_button, found_index=0).right_click_input()
                Desktop(backend="uia").Menu.child_window(title=ml_button, control_type="MenuItem",
                                                         found_index=0).click_input()

                start = time.time()
                dialog.child_window(title=ml_button).click_input()

                dialog.progressbar.exists()
                app.wait_cpu_usage_lower(threshold=5, timeout=1000)
                end = time.time()

                print "Time to complete %s ML action: %.2f" % (ml_button, end-start)
                return end-start

    else:
        start = time.time()
        dialog.child_window(title=ml_button).click_input()

        dialog.progressbar.exists()
        app.wait_cpu_usage_lower(threshold=5, timeout=1000)
        end = time.time()

        print "Time to complete %s ML action: %.2f" % (ml_button, end-start)
        return end-start
Exemple #24
0
def get_window_handle_list():
    output = ""
    for ele in Desktop(backend='uia').windows():
        control_type = ele.element_info.control_type
        title = ele.element_info.name
        class_name = ele.element_info.class_name
        content = u"{} {}\n".format('[ title={}, class_name={}, control_type={} ]'.format(title, class_name, control_type),
                                    ' [ handle=' + str(ele.handle) + ' ]')
        output += content
    return output
Exemple #25
0
    def findWindow(self, x, y):
        windowslist = []
        windows = Desktop(backend="uia").windows()
        for w in windows:
            windowslist.append(w.window_text())
        windowtitle = str([s for s in windowslist if "Minecraft*" in s][0])
        print(f"fWindow found: {windowtitle}")

        self.hWnd = win32gui.FindWindow(None, windowtitle)
        self.lParam = win32api.MAKELONG(x, y)
def find_main_window(name, wait=True):
    desktop = Desktop()
    main_window = desktop.window(best_match=name)

    if wait:
        main_window.wait("visible")

    main_window.print_control_identifiers()

    return main_window
Exemple #27
0
def tray_click(button_text: str):
    systray = Desktop(backend='uia').taskbar.child_window(
        title_re='.*Notification Area')

    for btn in systray.buttons():
        if btn.window_text() == button_text:
            btn.right_click_input()
            break
    else:
        raise ControlNotFound(button_text)
Exemple #28
0
def tray_menuclick(auto_id: str):
    tray_click('OnScreen Control')

    menu = Desktop(backend='uia').dialog.menu

    for item in menu.items():
        if item.automation_id() == auto_id:
            item.click_input()
            break
    else:
        raise ControlNotFound(auto_id)
Exemple #29
0
 def click_enter_workspace(self):
     '''
     点击【作业空间】
     :return:
     '''
     # 点击【作业空间】
     self.main_win[self.configs['teachermain']['toolbar']
                   ['BtnWorkspace']].click()
     Workspace_win = Desktop(backend="uia").window(
         **self.configs['workspace']['id'])
     Workspace_win.wait('visible', timeout=30)
Exemple #30
0
 def click_enter_portal(self):
     '''
     点击【云校园】
     :return:
     '''
     # 点击【云校园】
     self.main_win[self.configs['teachermain']['toolbar']
                   ['BtnPortabl']].click()
     IvyCloud_win = Desktop(backend="uia").window(
         **self.configs['portal']['id'])
     IvyCloud_win.wait('visible', timeout=30)