user889030
user889030

Reputation: 4754

Python PywinAuto : how to set file name in Open Dialog

I want to automate task in my app using PywinAuto python lib. My goal is to click the open file button and load the file. I had managed to start app and open the file Open Dialog however am unable to set filename to desire file path.

enter image description here

my code

app = application.Application(backend="uia")
app.start(MyAppPath).connect(title="MyApp",timeout = 5)
app.MyApp.wait('visible')
# click the open button
app.MyApp.Open.click()
app.MyApp.Open.print_control_identifiers()
# Open Dailogue identifiers dump : https://pastebin.com/nt5MpQJx
# tried to set file name , but not worked
app.Open.child_window(title="File name:", control_type="Text").Edit.SetText('C:\myfile.txt')

so any idea how to set the file name.

Upvotes: 1

Views: 1243

Answers (1)

user889030
user889030

Reputation: 4754

ok so i have fixed it by changing control_type="Text" to control_type="ComboBox" thought it should be Text but its ComboBox

working code

app = application.Application(backend="uia")
app.start(MyAppPath).connect(title="MyApp",timeout = 5)
app.MyApp.wait('visible')
# click the open button
app.MyApp.Open.click()
app.MyApp.Open.print_control_identifiers()
# Open Dailogue identifiers dump : https://pastebin.com/nt5MpQJx
# tried to set file name , but not worked
app.Open.child_window(title="File name:", control_type="ComboBox").Edit.SetText('C:\myfile.txt')

Upvotes: 1

Related Questions