Sign in to follow this  
Followers 0
timsta97

Currently Selected File

7 posts in this topic

How can I get the file that is currently selected in windows explorer?

Share this post


Link to post
Share on other sites



... get ...

get the name of?

ControlListView - GetSelected


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Does that return the file name?

Share this post


Link to post
Share on other sites

Why don't we read the help file?

http://www.autoitscript.com/autoit3/docs/functions/ControlListView.htm

"GetSelected" [, option]

Returns a string containing the item index of selected items. If option=0 (default) only the first selected item is returned. If option=1 then all the selected items are returned delimited by |, e.g: "0|3|4|10". If no items are selected a blank "" string is returned.

You can then try to pull the name from Controllistview-"GetText".

A quick and dirty way is to copy the file to the clipboard, then use Clipget()

Share this post


Link to post
Share on other sites

Like TurionAltec said - you can copy the file name to the clipboard - if the name is what you are after.

I have an old script that I've not updated to use ControlListView - GetSelected & GetText.

It just sends

F2

ctrl-c

ESC

down

Switches to another window and sends

ctrl-v

tab

Then it starts all over again.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

One can simply send ^c right to explorer, without using F2 (rename) and the entire path and filename will be copied to the clipboard

If several files are selected, all of their paths will be copied to the clipboard, each on a new line.

HotKeySet("#a","_getfile")
While 1
    sleep(5000)
WEnd

Func _getfile()
    send("^c")
    sleep(500)
    ConsoleWrite(ClipGet()&@CR)
EndFunc

@herewasplato: It may be faster for you to read all the file names at once, store them in an array, switch to the other program, and input them one after another.

Share this post


Link to post
Share on other sites

I should probably just update to the listview functions - but in this case, the file names of interest are usually longer than I normally display in the detailed view of explorer. I run the script and it does everything pretty slowly to allow me to read/check the file names being transferred to the other app. More than once, I've had to stop it when I noticed something that I would like to change in the file names before going on.

The other app has field limit base on the width of the proportional fonts entered - i.e.

WWWW or

iiiiiiiiiiiiiiiii

So I watch for that too :-(

Speed is not much of a problem as it is only about 10 file names and I do this 4 or 5 times a day.

I've thought of some ways to speed it up, but I usually take this time to stretch my arms and neck :-)


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


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
Sign in to follow this  
Followers 0