Sign in to follow this  
Followers 0
Guest rathore

Get Selected File's Path

14 posts in this topic

#1 ·  Posted (edited)

======EDIT======

I'm VERY SORRY! didn't mean to post it twice! (slow connection made the page lost at first) Please moderator, delete on of them .

===============

Here's the situation:

I've an open folder in an explorer window. I want to get the complete path to the selected file (or folder) into a variable.

There's a way that works but is not cool at all!! Its like this:

- I turn on 'show path in title bar'

- Read folder from title bar.

- Send keys {F2, ctrl+c, enter} (copies file/folder name to clipboard)

- Then join the both.

Now I can't find a way to do it using some control functions (the elegant way!). Can anyone tell me if its possible using some better approach?

Thanx!

-rathore

Edited by rathore

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

That's very creative :whistle:

I can't think of a better solution, but I have an alternative: Use a shell extension that adds "Path to clipboard" to the context menu. Then Send("{APPSKEY}p") assuming the shell extension begins with the letter p and is the only context menu entry beginning with P.....

Try rjh extensions which also has other useful extensions.

Another way is to Compile the following script and place it in the in the 'SendTo' folder. However, the location of SendTo varies on Windows B)

; Put compiled version in the Send To menu
;   and it copies path(s) to clipboard

If $CmdLine[0] > 0 Then
  $tmp = ""
  For $i = 1 to $CmdLine[0]
    $tmp = $tmp & $CmdLine[$i] & @CRLF
  Next
  ClipPut( StringTrimRight($tmp,2) )
EndIf
Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

What about "display full path in address bar" + controlgettext ?

Lar.

Larry, I think that only gives you the path of the parent folder. The selected item doesn't appear in the AutoIt SPY thingy--you get info on file type/date/size/comments but not the name :whistle:

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Larry, I think that only gives you the path of the parent folder. The selected item doesn't appear in the AutoIt SPY thingy--you get info on file type/date/size/comments but not the name

yeah exactly! ... i've already tried that!

What about "display full path in address bar" + controlgettext ?

well that gets me nowhere as it still gets me folder name only. (i'd alredy tried that and was successful with that one too)

i can't use sendto or rjh extensions etc as i've to make it all very fast and automatic... like i hover my mouse over a file (very wishful eh?!) or select a file and autoit gets its path.

i'll see what else can be done.... any help or ideas are deeply appreciated!

thanx!

-rathore

Share this post


Link to post
Share on other sites

$a = FileOpenDialog ( "Path", @WorkingDir, "Select File (*.*)",4)
MsgBox(4096,"","Path to file is " & $a)


 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

Share this post


Link to post
Share on other sites

Hey CyberSlug, i thought over it again.... maybe context menu item IS a better way & i should go ahead with it!!!

thanx !

and beerman, this isn't the way i want it. thanx though.

-rathore

Share this post


Link to post
Share on other sites

i was wrong!

sending keystrokes DOES NOT stand a chance. I want a way to read the file path of the selected file continuously in the background. About once every second, so that if I select a different file, autoit would know.

i tried this too within a loop (hybrid of mine & Larry's way):

Send("{f2}")

$name=ControlGetText ( "", "", "Edit2" )

Send("{enter}")

(i had to reboot as the {enter} kept getting at the wrong place and there were 42 windows open!!

and i tried making a context menu extension that kept popping the menu all the time due to the {apps} key.

Please guys think of SOMETHING!! there's got to b a way!!! I'm no Autoit3 guru but i guess the answer should be in reading the text of some control.

Thanx!

Share this post


Link to post
Share on other sites

Send("{f2}")

$name=ControlGetText ( "", "", "Edit2" )

Send("{enter}")

i just tried it with a different key

Send("{f2}")
$name=ControlGetText ( "", "", "Edit2" )
Send("{esc}")

 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

Share this post


Link to post
Share on other sites

thanx beerman, i tried that too but... u see the {esc} keeps throwing away many normal uses like a right click menu.

maybe there is no unobtrusive way of doing it... :whistle:

Share this post


Link to post
Share on other sites

There is probably a way to do it with VBScript. You could use VBScript and AutoItX to do it.

Share this post


Link to post
Share on other sites

<You could use VBScript and AutoItX to do it.>

how exactly? well to be frank, beyond autoit/autoit3/batch i need to be spoonfed! (sheepish smile)

thanx!

Share this post


Link to post
Share on other sites

There is indeed a VBScript interface to access what you want (The ShellFolderView object has a FocusedItem property). But I haven't done enough VB stuff to write a script to show you an example.

Share this post


Link to post
Share on other sites

<The ShellFolderView object has a FocusedItem property>

I'll surely look into that. Thanx for helping!

Share this post


Link to post
Share on other sites

In case you've had a look at MyNotes script (Scripts and Scraps section) then u'd know why I needed to know a way of getting the path to selected file...

Even though I've done it using my not-so-elegant way, i'm still open for better suggestions. Please let me know if you can think of something ...

thanx!

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