Jump to content

How to click on a filename inside windows file open dialog - (Moved)


Recommended Posts

Hi

I am very new to AutoIT and just few days old...

I am using this to integrate with selenium Python. I've an app and have a situation where I must select "Browse" button which opens windows file open dialog box. From there I need to select a file for use by the application. I am able to achieve this though the below code.

ControlFocus("Open","","Edit1")
ControlSetText("Open","","Edit1","Folder name of the CSV file")
ControlClick("Open","","Button1")

This perfectly selects the file name. Now everytime the file name changes, I had to re-compile the script before feeding into selenium.

Instead I am thinking if this could be achieved in AutoIT.

Have just only one CSV file in the folder and make autoIT select this file using automatically (Using some wildcard somthing like *.* or *.csv)

Is there a way to choose the file name inside the file open dialog box so that the "file name" automatically gets carried to "File Open" text box and then the ControlClick("Open","","Button1") will do its job?

Appreciate your assistance here and apologies if this is not the right area to post a tech question.

 

Thanks

-Sriram

 

Link to post
Share on other sites
  • Moderators

Moved to the appropriate forum.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

Look at _FileListToArray using wild card, you will get all (or single) files(s),  After that it is pretty straightforward. 

Link to post
Share on other sites
2 hours ago, Nine said:

Look at _FileListToArray using wild card, you will get all (or single) files(s),  After that it is pretty straightforward. 

I tried using that but don't know how to use this exactly...Assuming there is only one file in the specified folder, would you mind sharing the code for selecting that file (without specifying the file name)?

PS: I've the code to set the control to the "File name" field (where you normally type the file name), open the file (filename hard coded). 

Appreciate your assistance here.

Link to post
Share on other sites
1 hour ago, Danp2 said:

Selenium would generally indicate web automation. Are you automating a web browser? If so, which one? Also, can you share the website?

P.S. I know that with webdriver, you can indicate the files to be uploaded without having to deal with the file open dialog. Have you looked into that?

Yes, it is automating of web browser. Though it can be done without having to open file dialog, I prefer opening the file dialog just to make sure that functionality works well. Thanks

Link to post
Share on other sites
Link to post
Share on other sites
8 hours ago, Nine said:

What have you tried so far ?  Please provide the code you have written so far, so we can build from it.

This is what I have so far:

ControlFocus("Open","","Edit1")
ControlSetText("Open","","Edit1","Folder name of the CSV file")
ControlClick("Open","","Button1")

After "Browse" button is clicked, I am focusing control on the "Open" dialog box, setting the file name in "File Open" text area and click the "Open" button which will paste the file name in the relevant field in the application.

All I want is: Instead of hard coding the file name and send it to autOIT, once I open the File open dialog box, I must be able to select whatever file present in the folder and open it.

 

Thanks again for your help.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...