I switch between several keyboard layouts and have made super primitive scripts with pywinauto to TAB and ENTER until the desired layout is added or removed, but it's not very reliable and i want to learn how to use pywinauto more intimately so i'm making ones that flex more pywinauto muscles.
My pywinauto install passes the self tests I've found, for instance i have no problem running:
I've been using SWAPY and Inspect.exe to make sure I'm using the proper class names and I'm testing each step of the way so I know I'm building it right, and I've already hit a snag.
Here's my code so far:
Do I need to use application.connect on the window somehow? intl.cpl isn't an application so do i need to use findwindows or something? I've been fiddling with it for a couple days and any help would be greatly appreciated.
My pywinauto install passes the self tests I've found, for instance i have no problem running:
from pywinauto.application import Application # Run a target application app = Application().start("notepad.exe") # Select a menu item app.UntitledNotepad.menu_select("Help->About Notepad") # Click on a button app.AboutNotepad.OK.click() # Type a text string app.UntitledNotepad.Edit.type_keys("pywinauto Works!", with_spaces = True)what i'm trying to do is pull up the intl.cpl window, which is the Region window, then select the blue text 'Language preferences'(i'm on windows 10), then select the proper layout to add or delete, then save and close. like i said i'm able to do this with a bunch of tabs and enters through pywinauto.keyboard.SendKeys but it's not very reliable.
I've been using SWAPY and Inspect.exe to make sure I'm using the proper class names and I'm testing each step of the way so I know I'm building it right, and I've already hit a snag.
Here's my code so far:
from pywinauto.application import Application app = Application().Start(cmd_line=u'control intl.cpl') window = app.Region window.Wait('ready') syslink = window.SysLink syslink.Click() app.Kill_()Whether i try it in the interpreter or from a script i get a timout error,
C:\Python35\practice>python pywinDV.py 2016-12-03 04:32:37,819 INFO: Imported existing <module 'comtypes.gen' from 'C:\\Python35\\lib\\site-packages\\comtypes\\gen\\__init__.py'> 2016-12-03 04:32:37,824 INFO: Using writeable comtypes cache directory: 'C:\Python35\lib\site-packages\comtypes\gen' Traceback (most recent call last): File "pywinDV.py", line 5, in <module> window.Wait('ready') File "C:\Python35\lib\site-packages\pywinauto\application.py", line 486, in wait wait_until(timeout, retry_interval, lambda: self.__check_all_conditions(check_method_names)) File "C:\Python35\lib\site-packages\pywinauto\timings.py", line 343, in wait_until raise err pywinauto.timings.TimeoutError: timed outSo it seems like I'm getting the timeout error because it's waiting for the window to be 'ready', but even when i change this to 'exists' i get the same error. it's as if i'm not connecting to the window properly in the first place. if i take the wait line out and try importing time and using time.sleep(0.5) i get a timout error from the next line requiring a wait signal. if i take everything out after and leave in the app.Kill_() it doesn't exit and the script ends without errors, so I'm pretty sure I'm just not connected to the window because I started it with cmd.
Do I need to use application.connect on the window somehow? intl.cpl isn't an application so do i need to use findwindows or something? I've been fiddling with it for a couple days and any help would be greatly appreciated.