سؤال

I'm trying to use HwndWrapper.Texts() which supposedly "Returns the text for each item of this control" but it only returns the tile which is u'Fight plan settings dialog', why is this happening?

The code is this:

prog=application.Application()
prog.connect_(path=r'D:\Thesis\Euroscope\Euroscope.exe')
w_handle = pywinauto.findwindows.find_windows(title=u'Fight plan setting dialog', class_name='#32770')[0]
window = prog.window_(handle=w_handle)
c=prog.Fightplansettingsdialog.Texts()

Here is a screen of the window I'm trying to copy from:

http://imageshack.us/photo/my-images/802/newpicturewe.png/

I spent the afternoon reading the pywinauto documentation and i can't manage to find a way to get the content of a window like the one before into a text file(except clicking and copying each item with DoubleClick() and then Ctrl+C with TypeKeys which is way too long). Any ideas?

Edit: Also, I found out that PrintControlIdentifiers can't be easily saved to a strings file. Doing c=prog.PrintControlIdentifiers() returns None when i ask for c. Any way around this?

Thank you

هل كانت مفيدة؟

المحلول

You may get all texts from a window by running through all children.

all_texts = []
for child in window.Children():
  all_texts.extend(child.Texts())
all_texts = filter(lambda t:t, all_texts) # clear empty texts

By the way, it seems the window should be called 'Flight plan...' :-)

PS. I am happy to help a virtual controller!

UKHH - MDN91

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top