# Better way to select file(s) ?

## Recommended Posts

Right now iam doing it like this. Is there a better way to do this? This is during a data import process.

##### Share on other sites

It really depends what you want to do. There are many ways to select files, but I would chose how based on what I was going to do next.

Perhaps you should explain a little more and post some code.

Monkey's are, like, natures humans.

##### Share on other sites

Use ControlSend() to send Shortcut hotkeys to the target window to open the Import dialog.

Use Au3Info to detect the controlID of the "File name:" input control and the "Open" button. Then use ControlSetText() to set the filenames to open and finally ControlClick() on the open button.

OS: Win10-1709 - 64bit - German, AutoIt Version: 3.3.14.2, AutoIt Editor: SciTE, Website: http://www.funk.eu, My unsolved Questions: Get default Window Size and Position, Rotate display by 270 degrees, Get Systray Icons, ...

##### Share on other sites

It really depends what you want to do. There are many ways to select files, but I would chose how based on what I was going to do next.

Perhaps you should explain a little more and post some code.

I do the same way as given in those pictures above.

The code for it is given below. Data is getting updated in those excel/ascii files and i import it into the charting software. Since i do it quite frequently (once every 30 secs), it wud be good, if there are any quicker ways to do it. The code given below may look primitive, but it is how i do it

WinActivate("Charting software","-")   ;Activate charting software
Sleep(200)
Sleep(200)
WinWaitActive("Open","Folder")   ;wait for Open dialog
WinMove("Open","FolderView",345,-590)
Mouseclick("left",495,-330,1,1)   ;Select POINTER folder
MouseClick("left",865,-255,1,1)   ;Click OK
Sleep(200)
MouseClick("right",520,-450,1,1)   ;Right click in open space
MouseMove(590,-415)   ;Mouse hover on Arrange icons
Sleep(200)
Send("t")   ;Select Arrange icons as per type
MouseClickDrag("left",842,-436,882,-345,1)   ;Left Click and drag mouse on 6 .csv files
MouseClick("left",865,-255,1,1)   ;Click OK
Edited by nbala75

##### Share on other sites

Use ControlSend() to send Shortcut hotkeys to the target window to open the Import dialog.

Use Au3Info to detect the controlID of the "File name:" input control and the "Open" button. Then use ControlSetText() to set the filenames to open and finally ControlClick() on the open button.

Hi Kafoo

I am not able to find ControlIDs for most of the items/fields. I tried using WinMenuSelectItem, even that doesnt work. How to go abt it?

I tried using class or classnameNN name...but it doesnt work

##### Share on other sites

Hu, looks like the program is using some custom control types, at least for the menu itself. Stick to your code up to and including "WinWaitActive("Open","Folder")", try to find controlIDs for the "Open" dialog itself, that seems to be pretty standard, at least from the looks, then only automate that part with controlsend() and controlclick(). Hint, you can add a list of full qualified paths to the input control ('"c:\test\text1.txt" "c:\test\text2.txt" "c:\test\text3.txt"') and don't need to browse for the correct folder.

OS: Win10-1709 - 64bit - German, AutoIt Version: 3.3.14.2, AutoIt Editor: SciTE, Website: http://www.funk.eu, My unsolved Questions: Get default Window Size and Position, Rotate display by 270 degrees, Get Systray Icons, ...

##### Share on other sites

Hu, looks like the program is using some custom control types, at least for the menu itself. Stick to your code up to and including "WinWaitActive("Open","Folder")", try to find controlIDs for the "Open" dialog itself, that seems to be pretty standard, at least from the looks, then only automate that part with controlsend() and controlclick(). Hint, you can add a list of full qualified paths to the input control ('"c:\test\text1.txt" "c:\test\text2.txt" "c:\test\text3.txt"') and don't need to browse for the correct folder.

thanx for explaining in very simple terms...i got it

except that i do not know how to select (controlsend) mutliple file names in the "Open Dialog/File name" edit field

I tried sending it with doublequotes(") OR comma(,) OR quotes(') OR Space( ) ...but nothing works

after wandering thru net , i have come back to u Mr Kafu...plz help me out

##### Share on other sites

You nearly got it , enclose all filenames with single quotes and the single filenames with double quotes. The single quote is for autoit to recognize a string, the double quote for the open dialog to separate the single files.

$sFiles = '"c:\test\text1.txt" "c:\test\text2.txt" "c:\test\text3.txt"' Edit: Btw, I'm currently tinkering on a similar program , only that I gave up the intraday approach and now I'm working on a daily basis ... Edit2: Or if you need to concatenate single strings, you'll have to consider that quotes are escaped by quotes (sounds silly, but it's a fact). $sFile1 = "c:\test\text1.txt"
$sFile2 = "c:\test\text2.txt"$sFiles = '"' & $sFile1 & '" "' &$sFile2 & '"'
MsgBox(0,"",$sFiles)$sFiles = """" & $sFile1 & """ """ &$sFile2 & """"
MsgBox(0,"",$sFiles) Edited by KaFu OS: Win10-1709 - 64bit - German, AutoIt Version: 3.3.14.2, AutoIt Editor: SciTE, Website: http://www.funk.eu, My unsolved Questions: Get default Window Size and Position, Rotate display by 270 degrees, Get Systray Icons, ... #### Share this post ##### Link to post ##### Share on other sites $sFile1 = "c:\test\text1.txt"
$sFile2 = "c:\test\text2.txt"$sFiles = '"' & $sFile1 & '" "' &$sFile2 & '"'
MsgBox(0,"",$sFiles)$sFiles = """" & $sFile1 & """ """ &$sFile2 & """"
MsgBox(0,"",$sFiles) Isn't that kind of a hard way to use doublequotes? If you want to use double quotes in the string you can put that directly between single quotes, just like the other way around... The following works just as well: $sFile1 = '"c:\test\text1.txt"'
$sFile2 = '"c:\test\text2.txt"'$sFiles = $sFile1 & " " &$sFile2
MsgBox(0,"",$sFiles) Roses are FF0000, violets are 0000FF... All my base are belong to you. #### Share this post ##### Link to post ##### Share on other sites $sFile1 = 'c:\test\text1.txt'
$sFile2 = 'c:\test\text2.txt'$sFiles = _Quote($sFile1) & " " & _Quote($sFile2)
MsgBox(0,"",$sFiles) Func _Quote($s)
Return '"' & \$s & '"'
EndFunc

I guess there are some dozened more ways to do it, as long as the resulting syntax is correct ...

OS: Win10-1709 - 64bit - German, AutoIt Version: 3.3.14.2, AutoIt Editor: SciTE, Website: http://www.funk.eu, My unsolved Questions: Get default Window Size and Position, Rotate display by 270 degrees, Get Systray Icons, ...

##### Share on other sites

Sorry to come back to u Kafu...it doesnt work and i cud not find a solution

As u had suggested in one of ur posts, that i can just give the correct path, without worrying to open the correct folder, i just gave like that enclosing the path within double quotes. The OPEN dialog doesnt give any error NOR it updates the quotes.

I tried searching thru folder options, control panel etc, but, cud not get what is wrong

just have a look at the pictures

when given like this, there is no error msg and no updation happens...

When multiple files selected inside the relevant Folder, then it is getting updated

Edited by nbala75

##### Share on other sites

Cant figure it out, sorry. Has to be something program specific, it works fine in a standard 'open' dialog.

OS: Win10-1709 - 64bit - German, AutoIt Version: 3.3.14.2, AutoIt Editor: SciTE, Website: http://www.funk.eu, My unsolved Questions: Get default Window Size and Position, Rotate display by 270 degrees, Get Systray Icons, ...

## Create an account

Register a new account

×

• Wiki

• Back

• Git