def shoot_rr_viewer(conf): app = Application(backend="win32").start(conf["path"]) app.wait_cpu_usage_lower() win = app.window(class_name="TMainForm") win.move_window(200, 200, 600, 400) app.wait_cpu_usage_lower() # ROSRaveReportsViewer.bmp win.capture_as_image().save("ROSRaveReportsViewer.bmp") win.close()
def test_wait_cpu_usage_lower_uia(self): """Test that wait_cpu_usage_lower() works correctly for UIA""" app = Application(backend='uia') app.start('notepad.exe') try: app.wait_cpu_usage_lower(threshold = 1.5, timeout = 30, usage_interval = 2) finally: app.kill() app.cpu_usage = mock.Mock(return_value=10) self.assertRaises( RuntimeError, app.wait_cpu_usage_lower, threshold = 9.0, timeout = 5, usage_interval = 0.5 )
def export_view(mod, pt_num, path_to_views, username=ACRONYM, password=ACRONYM): cmd_display(mod, 'downloading...') app = Application().start( cmd_line= u'"C:\\Program Files (x86)\\Solid Edge TC Manual View\\Solid Edge TC Manual View.exe"' ) app.LoginForm.wait('ready', timeout=30) app.LoginForm.Edit5.set_edit_text(username) app.LoginForm.Edit4.set_edit_text(password) app.LoginForm.Login.click_input() time.sleep(5) app.PrincipalForm.wait('ready') app.PrincipalForm.Edit2.set_edit_text(pt_num) app.PrincipalForm.Search.click_input() time.sleep(3) if findwindows.find_windows(title='Search error'): print('Search Error: PT number invalide ') window = app.Dialog window.wait('ready') window.close() app.PrincipalForm.type_keys('%{F4}') else: app.PrincipalForm[u'4'].type_keys( path_to_views) #loop through the modules files app.PrincipalForm[u'3'].type_keys("{DOWN}") app.PrincipalForm.Export.click_input() app.wait_cpu_usage_lower( threshold=5) # wait until CPU usage is lower than 5% def detecting_pdf(): return any(glob.glob(os.path.join(path_to_views, r'*\*.pdf'))) wait_until(1000, 5.00, detecting_pdf, True) cmd_display(mod, 'exported') #close the popup windows & app window = app.Dialog button = window.OK button.click_input() #close principal form app.PrincipalForm.type_keys('%{F4}') # close an active window with Alt+F4 time.sleep(3)
class WindowWithoutMessageLoopFocusTests(unittest.TestCase): """ Regression unit tests for setting focus when window does not have a message loop. """ def setUp(self): """Set some data and ensure the application is in the state we want""" Timings.fast() self.app1 = Application().start(u"cmd.exe", create_new_console=True, wait_for_idle=False) self.app2 = Application().start( os.path.join(mfc_samples_folder, u"CmnCtrl2.exe")) self.app2.wait_cpu_usage_lower(threshold=1.5, timeout=30, usage_interval=1) def tearDown(self): """Close the application after tests""" self.app1.kill() self.app2.kill() def test_issue_270(self): """ Set focus to a window without a message loop, then switch to a window with one and type in it. """ self.app1.window().set_focus() self.app1.wait_cpu_usage_lower(threshold=1.5, timeout=30, usage_interval=1) # pywintypes.error: # (87, 'AttachThreadInput', 'The parameter is incorrect.') self.app2.window().edit.type_keys("1") # cmd.exe into python.exe; pywintypes.error: # (87, 'AttachThreadInput', 'The parameter is incorrect.') # python.exe on its own; pywintypes.error: # (0, 'SetForegroundWindow', 'No error message is available') self.assertTrue(self.app2.window().is_active())
class OwnerDrawnMenuTests(unittest.TestCase): """Unit tests for the OWNERDRAW menu items""" def setUp(self): """Set some data and ensure the application is in the state we want""" Timings.defaults() self.app = Application().start(os.path.join(mfc_samples_folder, u"BCDialogMenu.exe")) self.dlg = self.app.BCDialogMenu self.app.wait_cpu_usage_lower(threshold=1.5, timeout=30, usage_interval=1) self.dlg.wait('ready') def tearDown(self): """Close the application after tests""" self.app.kill() def testCorrectText(self): menu = self.dlg.menu() self.assertEqual(u'&New', menu.get_menu_path('&File->#0')[-1].text()[:4]) self.assertEqual(u'&Open...', menu.get_menu_path('&File->#1')[-1].text()[:8])
class WindowWithoutMessageLoopFocusTests(unittest.TestCase): """ Regression unit tests for setting focus when window does not have a message loop. """ def setUp(self): """Set some data and ensure the application is in the state we want""" Timings.fast() self.app1 = Application().start(u"cmd.exe", create_new_console=True, wait_for_idle=False) self.app2 = Application().start(os.path.join( mfc_samples_folder, u"CmnCtrl2.exe")) self.app2.wait_cpu_usage_lower(threshold=1.5, timeout=30, usage_interval=1) def tearDown(self): """Close the application after tests""" self.app1.kill() self.app2.kill() def test_issue_270(self): """ Set focus to a window without a message loop, then switch to a window with one and type in it. """ self.app1.window().set_focus() self.app1.wait_cpu_usage_lower(threshold=1.5, timeout=30, usage_interval=1) # pywintypes.error: # (87, 'AttachThreadInput', 'The parameter is incorrect.') self.app2.window().edit.type_keys("1") # cmd.exe into python.exe; pywintypes.error: # (87, 'AttachThreadInput', 'The parameter is incorrect.') # python.exe on its own; pywintypes.error: # (0, 'SetForegroundWindow', 'No error message is available') self.assertTrue(self.app2.window().is_active())
class OwnerDrawnMenuTests(unittest.TestCase): """Unit tests for the OWNERDRAW menu items""" def setUp(self): """Set some data and ensure the application is in the state we want""" Timings.Defaults() self.app = Application().Start( os.path.join(mfc_samples_folder, u"BCDialogMenu.exe")) self.dlg = self.app.BCDialogMenu self.app.wait_cpu_usage_lower(threshold=1.5, timeout=30, usage_interval=1) self.dlg.wait('ready') def tearDown(self): """Close the application after tests""" self.app.kill_() def testCorrectText(self): menu = self.dlg.Menu() self.assertEqual(u'&New', menu.GetMenuPath('&File->#0')[-1].Text()[:4]) self.assertEqual(u'&Open...', menu.GetMenuPath('&File->#1')[-1].Text()[:8])
def _toggle_notification_area_icons(show_all=True, debug_img=None): """ A helper function to change 'Show All Icons' settings. On a succesful execution the function returns an original state of 'Show All Icons' checkbox. The helper works only for an "English" version of Windows, on non-english versions of Windows the 'Notification Area Icons' window should be accessed with a localized title" """ Application().start(r'explorer.exe') class_name = 'CabinetWClass' def _cabinetwclass_exist(): "Verify if at least one active 'CabinetWClass' window is created" l = findwindows.find_elements(active_only=True, class_name=class_name) return (len(l) > 0) wait_until(_ready_timeout, _retry_interval, _cabinetwclass_exist) handle = findwindows.find_elements(active_only=True, class_name=class_name)[-1].handle window = WindowSpecification({'handle': handle, 'backend': 'win32', }) explorer = Application().connect(process=window.process_id()) cur_state = None try: # Go to "Control Panel -> Notification Area Icons" cmd_str = r'control /name Microsoft.NotificationAreaIcons' for _ in range(3): window.wait("ready", timeout=_ready_timeout) window.AddressBandRoot.click_input() explorer.wait_cpu_usage_lower(threshold=2, timeout=_ready_timeout) window.type_keys(cmd_str, with_spaces=True, set_foreground=True) # verfiy the text in the address combobox after type_keys finished cmbx_spec = window.AddressBandRoot.ComboBoxEx if cmbx_spec.exists(timeout=_ready_timeout, retry_interval=_retry_interval): texts = cmbx_spec.texts() if texts and texts[0] == cmd_str: break # Send ESCs to remove the invalid text window.type_keys("{ESC}" * 3) # Send 'ENTER' separately, this is to make sure # the window focus hasn't accidentally been lost window.type_keys( '{ENTER}', with_spaces=True, set_foreground=True ) explorer.wait_cpu_usage_lower(threshold=5, timeout=_ready_timeout) # Get the new opened applet notif_area = Desktop().window(title="Notification Area Icons", class_name=class_name) notif_area.wait("ready", timeout=_ready_timeout) cur_state = notif_area.CheckBox.get_check_state() # toggle the checkbox if it differs and close the applet if bool(cur_state) != show_all: notif_area.CheckBox.click_input() notif_area.Ok.click_input() explorer.wait_cpu_usage_lower(threshold=5, timeout=_ready_timeout) except Exception as e: if debug_img: from PIL import ImageGrab ImageGrab.grab().save("%s.jpg" % (debug_img), "JPEG") l = pywinauto.actionlogger.ActionLogger() l.log("RuntimeError in _toggle_notification_area_icons") raise e finally: # close the explorer window window.close() return cur_state
class IDS: def __init__(self, path, obj_tree_path, msr_tree_path): self.path = path self.obj_tree_path = obj_tree_path self.msr_tree_path = msr_tree_path self.screen_rect = RECT(0, 0, win32api.GetSystemMetrics(0), win32api.GetSystemMetrics(1)) self.delay_win_active = .5 self.app = None self.ids = None self.params_index = None self.do_common_MainWindow = True self.do_common_MainWindow_MainMenu = True @classmethod def get_corepopup_rect(cls, popup) -> RECT: # popup: WindowSpecification rect = popup.rectangle() if popup.menu().item_count() > 17: r = popup.menu().item(17).rectangle() # Диагностика rect.bottom = r.bottom + 5 return rect @classmethod def get_suffixed_name(cls, name: str, suffix: str = None) -> str: return name.format(suffix if suffix is not None else "") def shoot(self): pass def shoot_common(self): if self.do_common_MainWindow: self.MainWindow() if self.do_common_MainWindow_MainMenu: self.MainWindow_MainMenu("_Common") self.MainWindow_NewObject_Call() self.MainWindow_NewObject() self.MainWindow_NewZamer_Call() self.MainWindow_PSP_Call() self.PSP() self.Zamer_Show_Call() self.Zamer_Cascade_Call() self.Zamer_ShowMarka_Call() self.Zamer_Diagnos_Call() self.MainWindow_Export_Call() self.Export_Params() self.MainWindow_Import_Call() self.Import_Params() self.Import_Params_Extra() self.Params_SignalsShow() self.Params_Reporter() self.Params_Systems() def start_app(self): self.app = Application(backend="win32").start(self.path) self.app.wait_cpu_usage_lower() self.ids = self.app.window(class_name="TIDSMainForm") self.ids.move_window(200, 200, 600, 400) self.app.wait_cpu_usage_lower() # определяем индекс пункта меню Сервис->Параметры self.params_index = self.ids.menu_item( "#1").sub_menu().item_count() - 1 def stop_app(self): if self.ids is not None and self.ids.exists(): self.ids.close() time.sleep(1) def MainWindow(self, suffix: str = None): filename = self.get_suffixed_name("MainWindow{}.bmp", suffix) treeview_element_colapse(self.ids.TreeView.tree_root()) self.ids.capture_as_image().save(filename) def MainWindow_MainMenu(self, suffix: str = None): filename = self.get_suffixed_name("MainWindow_MainMenu{}.bmp", suffix) treeview_element_colapse(self.ids.TreeView.tree_root()) self.ids.menu().highlight_and_capture("#1->#{}".format( self.params_index), filename) # Сервис->Параметры->xxx SendKeys("{ESC}{ESC}{ESC}") # закрываем меню def MainWindow_NewObject_Call(self): self.capture_popupmenu_item( [0, 0], "#0", "MainWindow_NewObject_Call.bmp") # Добавить объект SendKeys("{ESC}") # закрываем меню def MainWindow_NewObject(self): self.select_popupmenu_item([ 0, ], "#0") # Добавить объект time.sleep(self.delay_win_active) self.app.TStructureAddForm.capture_as_image().save( "MainWindow_NewObject.bmp") self.app.TStructureAddForm.close_alt_f4() def MainWindow_NewZamer_Call(self): self.capture_popupmenu_item( self.obj_tree_path, "#2", "MainWindow_NewZamer_Call.bmp") # Добавить измерение SendKeys("{ESC}") # закрываем меню def MainWindow_PSP_Call(self): self.capture_popupmenu_item(self.obj_tree_path, "#12", "MainWindow_PSP_Call.bmp") # Паспорт SendKeys("{ESC}") # закрываем меню def PSP(self): # паспорт self.select_popupmenu_item(self.obj_tree_path, "#12") # Паспорт time.sleep(self.delay_win_active) # изменение марки self.psp_change_marka() # подтверждение сохранения паспорта self.app.TMessageForm.capture_as_image().save("PSP_SaveConfirm.bmp") self.app.TMessageForm.Button3.click() # Да time.sleep(self.delay_win_active) # подтверждение сохранения марки self.app.TMessageForm.capture_as_image().save( "PSP_MarkaSaveConfirm.bmp") # TODO: в окне выводится название марки self.app.TMessageForm.Button2.click() # Да time.sleep(self.delay_win_active) # инфо о существовании похожей марки (opt) if self.app.TMessageForm.exists( ) and self.app.TMessageForm.control_count() == 1: SendKeys("{ESC}") # закрываем сообщение time.sleep(self.delay_win_active) # подтверждение изменения марок в замерах (opt) if self.app.TMessageForm.exists(): self.app.TMessageForm.capture_as_image().save( "PSP_MarkaSaveInZamersConfirm.bmp") SendKeys("{ESC}") # закрываем сообщение else: print("skip PSP_MarkaSaveInZamersConfirm.bmp") def psp_change_marka(self): pass def Zamer_Show_Call(self): self.capture_popupmenu_item(self.msr_tree_path, "#14", "Zamer_Show_Call.bmp") # Просмотр SendKeys("{ESC}") # закрываем меню def Zamer_Cascade_Call(self): self.capture_popupmenu_item( self.obj_tree_path, "#15", "Zamer_Cascade_Call.bmp") # Просмотр каскада SendKeys("{ESC}") # закрываем меню def Zamer_ShowMarka_Call(self): self.capture_popupmenu_item( self.msr_tree_path, "#16", "Zamer_ShowMarka_Call.bmp") # Измерение. Просмотр марки SendKeys("{ESC}") # закрываем меню def Zamer_Diagnos_Call(self): self.capture_popupmenu_item(self.msr_tree_path, "#17", "Zamer_Diagnos_Call.bmp") # Диагностика SendKeys("{ESC}") # закрываем меню def MainWindow_Export_Call(self): treeview_element_colapse(self.ids.TreeView.tree_root()) self.ids.menu().highlight_and_capture( "#1->#4", "MainWindow_Export_Call.bmp") # Сервис->Экспорт SendKeys("{ESC}{ESC}") # закрываем меню def Export_Params(self): treeview_element_colapse(self.ids.TreeView.tree_root()) self.ids.menu_select("#1->#4") # Сервис->Экспорт time.sleep(self.delay_win_active) self.app.TExportInitForm.capture_as_image().save("Export_Params.bmp") self.app.TExportInitForm.close_alt_f4() def MainWindow_Import_Call(self): treeview_element_colapse(self.ids.TreeView.tree_root()) self.ids.menu().highlight_and_capture( "#1->#5", "MainWindow_Import_Call.bmp") # Сервис->Импорт SendKeys("{ESC}{ESC}") # закрываем меню def Import_Params(self): treeview_element_colapse(self.ids.TreeView.tree_root()) self.ids.menu_select("#1->#5") # Сервис->Импорт time.sleep(self.delay_win_active) self.app.TImportInitForm.capture_as_image().save("Import_Params.bmp") self.app.TImportInitForm.close_alt_f4() def Import_Params_Extra(self): treeview_element_colapse(self.ids.TreeView.tree_root()) self.ids.menu_select("#1->#5") # Сервис->Импорт self.app.TImportInitForm.Button1.click() # Настройки time.sleep(self.delay_win_active) self.app.TImportSettingsForm.capture_as_image().save( "Import_Params_Extra.bmp") SendKeys("{ESC}{ESC}") # закрываем меню def Params(self, first: str, pages=None): # Params_Common{}.bmp # Params_Common2{}.bmp # Params_RB{}.bmp # Params_UserPointNames{}.bmp # TODO: дефолтные параметры # TODO: у TransVS, StatorTG, RF и FreeFormat параметр Использовать стандартные обозначения точек... выключен # по умолчанию self.ids.menu_select("#1->#{}->#0".format( self.params_index)) # Сервис->Параметры->Общие self.app.TParamsForm.capture_as_image().save("{}.bmp".format(first)) if pages is not None and isinstance(pages, list) and len(pages) > 0: SendKeys("{TAB}{TAB}") # подготавливаемся к переключению закладок for p in pages: SendKeys("{RIGHT}") # переключаемся на следующую закладку time.sleep(self.delay_win_active) self.app.TParamsForm.capture_as_image().save( "{}.bmp".format(p)) self.app.TParamsForm.close_alt_f4() def Params_RB_ExtraVibroLevels(self): self.ids.menu_select("#1->#{}->#0".format( self.params_index)) # Сервис->Параметры->Общие SendKeys( "{TAB}{TAB}{RIGHT}{RIGHT}") # переключаемся на закладку Подшипники self.app.TParamsForm["...TBitBtn"].click() time.sleep(self.delay_win_active) # TODO: дефолтные параметры self.app.TParams_RB_PowerInBandsForm.capture_as_image().save( "Params_RB_ExtraVibroLevels.bmp") self.app.TParams_RB_PowerInBandsForm.close_alt_f4() self.app.TParamsForm.close_alt_f4() @staticmethod def Params_UserPointNames_Edit(suffix: str): print("skip Params_UserPointNames{}_Edit.bmp".format(suffix)) # self.ids.menu_select("#1->#{}->#0".format(self.params_index)) # Сервис->Параметры->Общие # # даже если закладок всего 3, то лишние {RIGHT} не "зациклят" переключение, а "остановятся" на последней # SendKeys("{TAB}{TAB}{RIGHT}{RIGHT}{RIGHT}") # переключаемся на закладку Формирование измерения # # TODO: self.app.TParamsForm["---TSpeedButton"].click() # time.sleep(self.delay_win_active) # # TODO: дефолтные параметры # self.app.TParams_ZamerFormirov_PointsNameAlly_Form.capture_as_image().save("Params_UserPointNames{}_Edit.bmp".format(suffix)) # self.app.TParams_ZamerFormirov_PointsNameAlly_Form.close_alt_f4() # self.app.TParamsForm.close_alt_f4() def Params_SignalsShow(self): self.ids.menu_select("#1->#{}->#1".format( self.params_index)) # Сервис->Параметры->Просмотр сигналов self.app.TGrafSetups_Params_Form.Button9.click( ) # По умолчанию (дефолтные параметры) self.app.TGrafSetups_Params_Form.capture_as_image().save( "Params_SignalsShow.bmp") SendKeys( "{TAB}{TAB}{RIGHT}" ) # переключаемся на закладку Параметры 2 с кнопки По умолчанию self.app.TGrafSetups_Params_Form.capture_as_image().save( "Params_SignalsShow_p2.bmp") self.app.TGrafSetups_Params_Form.close_alt_f4() def Params_Reporter(self): # TODO: дефолтные параметры self.ids.menu_select("#1->#{}->#2".format( self.params_index)) # Сервис->Параметры->Формирование отчёта self.app.TSetupReporterForm.capture_as_image().save( "Params_Reporter_p1.bmp") SendKeys("{TAB}{TAB}{RIGHT}") # переключаемся на закладку Колонтитулы self.app.TSetupReporterForm.capture_as_image().save( "Params_Reporter_p2.bmp") SendKeys("{RIGHT}") # переключаемся на закладку Шрифт, поля self.app.TSetupReporterForm.capture_as_image().save( "Params_Reporter_p3.bmp") self.app.TSetupReporterForm.close_alt_f4() def Params_Systems(self): """ окна с параметрами экспертных систем """ # TODO: дефолтные параметры params_sub_count = self.ids.menu_item("#1->#{}".format( self.params_index)).sub_menu().item_count() for i in range(3, params_sub_count): self.ids.menu_select("#1->#{}->#{}".format( self.params_index, i)) # Сервис->Параметры->i if self.app.top_window().class_name() == "TSysParamsEditingForm": image_name = "Params_RB.bmp" else: print("unknown params window {}".format( self.app.top_window().class_name())) continue self.app.top_window().capture_as_image().save(image_name) if self.app.top_window().class_name() == "TSysParamsEditingForm": # не находит по TSysParamsEditingForm, используем top_window() self.app.top_window().Button5.click() # Настройка каналов time.sleep(self.delay_win_active) self.app.TParams_RollingBearing_Channels_Form.capture_as_image( ).save("Params_RB_ChannsSetup_SVK.bmp") self.app.TParams_RollingBearing_Channels_Form.close_alt_f4() self.app.top_window().close_alt_f4() def capture_popupmenu_item(self, tree_path, menu_path, filename): self.ids.TreeView.get_item(tree_path).click_input(button="right") r = self.get_corepopup_rect(self.app.PopupMenu) self.app.PopupMenu.wrapper_object().highlight_and_capture( menu_path, filename, r) def select_popupmenu_item(self, tree_path, menu_path): self.ids.TreeView.get_item(tree_path).click_input(button="right") self.app.PopupMenu.menu_item(menu_path).click_input()
# dlg = app["Navicat Premium"] # # 选择菜单 # menu = dlg["menu"] # # 选择菜单项:文件 # file = menu.child_window(title="文件", control_type="MenuItem") # # 点击文件 # file.click_input() # # 点击新建连接 # menu.item_by_path("文件->新建连接").click_input() # # 点击MySQL... # menu.item_by_path("文件->新建连接->MySQL...").click_input() # # 选择新建连接的窗口 # new_dlg = app["MySQL - 新建连接"] # # 等待窗口处于可见状态 # # new_dlg.wait(wait_for="ready", timeout=10, retry_interval=1) # # print("等待通过,当前新建连接的窗口处于可见状态") # # 等待窗口处于不可见状态-关闭[MySQL - 新建连接] 窗口则通过 # new_dlg.wait_not(wait_for_not="ready", timeout=10, retry_interval=1) # print("等待通过,当前新建的窗口不处于可见状态") # 等待机制三:wait_cpu_usage_lower 方法 ,通过夜深模拟器的 pid(进程ID) 进行连接 app = Application().connect(process=6044) app.wait_cpu_usage_lower(threshold=5, timeout=5, usage_interval=1) print("等待通过,CPU占用率低于%5")
from pywinauto.application import Application import datetime import psutil print(datetime.datetime.now()) print(psutil.cpu_percent()) print(psutil.virtual_memory()) app = Application().start( "C:\\Users\\hp\\AppData\\Local\\atom\\atom.exe") #put exe of vs code here app.wait_cpu_usage_lower(threshold=1) #app.WindowSpecification.wait('ready', timeout=None).TypeKeys('%i') print(datetime.datetime.now()) print(psutil.cpu_percent()) print(psutil.virtual_memory())
# # Often, when you click/right click on an icon, you get a popup menu. # The thing to remember at this point is that the popup menu is a part # of the application being automated not part of explorer. # connect to outlook #outlook = Application.connect(path='outlook.exe') # click on Outlook's icon #taskbar.ClickSystemTrayIcon("Microsoft Outlook") # Select an item in the popup menu #outlook.PopupMenu.Menu().get_menu_path("Cancel Server Request")[0].click() app.wait_cpu_usage_lower(threshold=5) # wait until CPU usage is lower than 5% app.SendKeys('^a^c') # select all (Ctrl+A) and copy to clipboard (Ctrl+C) app.SendKeys('+{INS}') # insert from clipboard (Shift+Ins) app.SendKeys('%{F4}') # close an active window with Alt+F4 # {SCROLLLOCK}, {VK_SPACE}, {VK_LSHIFT}, {VK_PAUSE}, {VK_MODECHANGE}, # {BACK}, {VK_HOME}, {F23}, {F22}, {F21}, {F20}, {VK_HANGEUL}, {VK_KANJI}, # {VK_RIGHT}, {BS}, {HOME}, {VK_F4}, {VK_ACCEPT}, {VK_F18}, {VK_SNAPSHOT}, # {VK_PA1}, {VK_NONAME}, {VK_LCONTROL}, {ZOOM}, {VK_ATTN}, {VK_F10}, {VK_F22}, # {VK_F23}, {VK_F20}, {VK_F21}, {VK_SCROLL}, {TAB}, {VK_F11}, {VK_END}, # {LEFT}, {VK_UP}, {NUMLOCK}, {VK_APPS}, {PGUP}, {VK_F8}, {VK_CONTROL}, # {VK_LEFT}, {PRTSC}, {VK_NUMPAD4}, {CAPSLOCK}, {VK_CONVERT}, {VK_PROCESSKEY}, # {ENTER}, {VK_SEPARATOR}, {VK_RWIN}, {VK_LMENU}, {VK_NEXT}, {F1}, {F2}, # {F3}, {F4}, {F5}, {F6}, {F7}, {F8}, {F9}, {VK_ADD}, {VK_RCONTROL}, # {VK_RETURN}, {BREAK}, {VK_NUMPAD9}, {VK_NUMPAD8}, {RWIN}, {VK_KANA},
import time from pywinauto.application import Application from win32con import * import sys ACCOUNT = sys.argv[1] PASSWORD = sys.argv[2] print("Launching iTunes...") app = Application().start(r"C:\Program Files\iTunes\iTunes.exe") app.wait_cpu_usage_lower() time.sleep(3) def debugTopWin(): print("-- Cur top win: %s" % app.top_window().wait('exists')) def cleanAllDialog(): while True: topwin = app.top_window().wait('exists') if 'Dialog' in topwin.class_name(): print(" Closing dialog %s" % topwin.window_text()) app.top_window().Button0.click() else: break app.wait_cpu_usage_lower() time.sleep(3)