Python 3.x python pywinauto file selection dialog

Python 3.x python pywinauto file selection dialog,python-3.x,openfiledialog,pywinauto,Python 3.x,Openfiledialog,Pywinauto,I am in the process of automating a firmware update for a specific component we use a work a lot. I have the automation of the gui completed (and working) except for this particular screen. What I need to do, is have the program automatically navigate to the correct folder (standardized across machines) and select the correct file to use for the update. Here is my code so far: from pywinauto.application import Application app = Application(backend='win32').connect(title_re=".*EBDS*",

I am in the process of automating a firmware update for a specific component we use a work a lot. I have the automation of the gui completed (and working) except for this particular screen.

What I need to do, is have the program automatically navigate to the correct folder (standardized across machines) and select the correct file to use for the update.

Here is my code so far:

from pywinauto.application import Application

app = Application(backend='win32').connect(title_re=".*EBDS*", found_index=0)

main_dlg = app.window(title_re=".*EBDS*", found_index=0)

main_dlg.child_window(title="Launch Control Panel", control_type="System.Windows.Forms.Button").click()

sub_dlg = app.window(title_re=".*Bill Acceptor*", found_index=0)

sub_dlg.child_window(title="Open", control_type="System.Windows.Forms.Button").click()

sub_dlg.child_window(title="Download", control_type="System.Windows.Forms.Button").click()

file_dlg = app.window(title_re=".*download*", found_index=0)

It has a couple sub windows that pop up after clicking, thus the main_dlg, sub_dlg, and file_dlg.

enter image description here

I have already told it to select the download button, and it pops up the "select a file to download" window.

What I need to do now is be able to specify the path (where it says This PC), change the file type (currently says Bin files), and select the correct file.

I have done a "print control identifiers" and here is the link to the txt file of that output (it's over 3k lines, so I didn't want to paste it here) Control Identifiers .txt

What I then did was I correctly (manually) went through the steps to get it where it needs to be, and did another "print control identifiers." Again, this is over 3k lines long, so here is a Link to that output.

Assuming that I'm doing this right, the file path location in the gui is:

file_dlg.child_window(title="Select a file to download.", class_name='#32770').child_window(class_name="WorkerW").child_window(class_name="ReBarWindow32").child_window(class_name="Address Band Root").child_window(class_name="msctls_progress32").child_window(class_name="Breadcrumb Parent").child_window(title=".*Address:*", class_name="ToolbarWindow32")

The question is, how do I interact with that object specifically? A .click() or .sendkeys() both error out.

Bonus points if you can figure out how to change the file type.

I'm open to an easier/different way of doing this, however this has to be deployable to a couple hundred machines that don't have the same screen size, ergo I cannot use pyautogui and pixel counts.

Any ideas?


#1

You can enter the full file path to the edit box and click "Open" button. It should look like this:

file_dlg = app.window(title_re=".*Select a file to download*", found_index=0)
file_dlg.FileNameEdit.set_edit_text("full_path_to_file")
file_dlg.child_window(title="&Open", control_type="Button").click()

I assume you have to bypass .click_input() and .type_keys(...) usage as they require active desktop which is hard to maintain on a big pool of machines.


#2

Thank you for that answer, it is very helpful. I am able to use that to say the file name, however when I click the "open" button, it says invalid file. I think what I need is for the file path to be specified in the top bar. Am I missing something as far as the navigation bar?

#3

I now have identified the address bar as AddressEditBox, and can highlight it. Now I am having a very difficult time trying to send it information to change the directory that we are looking at. Any pointers?

#4

It looks like incorrect behavior of the app or incorrect full path at some small point (escape sequences?). All applications should accept full path in such dialog. I can take a look into address bar change, but it needs some time for experiments.