Jump to content

Selected File


Digisoul
 Share

Recommended Posts

Hi guys ,

Firstly I want to tell you that what are my requirements,

I want to make a program which give you some information , of any selected file in Explorer, I just tried some control functions, but its just give me , some upper controls.

e.g. if any user select any file in explorer, my app will show its information ( path, version, size ).

Now problem is how can I script for getting info about current selected file ?

Thanks in Advance for your help .

Edited by Digisoul

73 108 111 118 101 65 117 116 111 105 116

Link to comment
Share on other sites

$Window = WinGetTitle("[ACTIVE]", "")
$CLVItem = ControlListView($Window, "FolderView", "SysListView321", "GetSelected")
$Item = ControlListView($Window, "FolderView", "SysListView321", "GetText", $CLVItem)

Desktop is a ListView control... with that code u get the name of the file selected ( on desktop, folder )

Link to comment
Share on other sites

A great way of doing that is right-clicking on the file and then go to "properties" ;)

On the other hand, there's a bunch of FileGet*() functions that could do the job.

If you want to add a special context menu in explorer for all kinds of files (so you can do it directly from windows explorer), you are gonna have to play with the registry. I think that if you want a context menu for all kinds of files, you have to edit HKCR\*\Shell (can't access regedit, limited user, not sure if this is the key). Add a new key there like "File Properties" and then a new one inside this last one called "Command". It should look like this:

HKCR\*\shell\File Properties\Command

Doule click the (Default) value and add this information:

"path to your app""%1"

This SHOULD (haven't done it in a while, so not sure, this is from the top of my head) add a new context menu for all kinds of files that says "File properties" and when you click on it explorer will send the path to the file(s) to your app which you will get using the special variable $CMDLINE and/or $CMDLINERAW. Look them up in the help file.

Link to comment
Share on other sites

  • 2 weeks later...

Thank You Very Much for your reply Guys

A great way of doing that is right-clicking on the file and then go to "properties" :)

On the other hand, there's a bunch of FileGet*() functions that could do the job.

If you want to add a special context menu in explorer for all kinds of files (so you can do it directly from windows explorer), you are gonna have to play with the registry. I think that if you want a context menu for all kinds of files, you have to edit HKCR\*\Shell (can't access regedit, limited user, not sure if this is the key). Add a new key there like "File Properties" and then a new one inside this last one called "Command". It should look like this:

HKCR\*\shell\File Properties\Command

Doule click the (Default) value and add this information:

"path to your app""%1"

This SHOULD (haven't done it in a while, so not sure, this is from the top of my head) add a new context menu for all kinds of files that says "File properties" and when you click on it explorer will send the path to the file(s) to your app which you will get using the special variable $CMDLINE and/or $CMDLINERAW. Look them up in the help file.

1stly I want to say that you cant write Registry value in HKCR\*\Shellex because its only execute .dll handle. For Writing in shellex you will need to create shell extension which is little difficult work. 1 thing more if any user select 2 files the application will not pass all the paths, because Shell will execute your application 2 times. Because of %1 variable .

73 108 111 118 101 65 117 116 111 105 116

Link to comment
Share on other sites

$Window = WinGetTitle("[ACTIVE]", "")
$CLVItem = ControlListView($Window, "FolderView", "SysListView321", "GetSelected")
$Item = ControlListView($Window, "FolderView", "SysListView321", "GetText", $CLVItem)

Desktop is a ListView control... with that code u get the name of the file selected ( on desktop, folder )

Your Code is Good & I Use this code for getting the files Path but not worked for me.

Opt("SendKeyDelay", 0)
Local $path,$temp
$hWnd = WinGetHandle("[Active]")
While 1
Sleep(20)
If WinActive("[CLASS:CabinetWClass]") Then
$CLVItem = ControlListView("[CLASS:CabinetWClass]", "FolderView", "SysListView321", "GetSelected")
$Item = ControlListView("[CLASS:CabinetWClass]","FolderView", "SysListView321", "GetText", $CLVItem)
If $CLVItem <> "" Then
    If $temp <> $Item Then
    ClipPut("")
    Send("^c")
    $temp = $item
    Local $timer = TimerInit()
    Do
        $path = ClipGet()
    Until $path Or TimerDiff($timer) > 500
    ClipPut("")
    ConsoleWrite($path & @CRLF)
    EndIf
EndIf
EndIf

WEnd

So Is it there any other way to get any selected files path. My requirement is that if any user select (means click on) any file my app will show its status, e.g. size, path, type.

73 108 111 118 101 65 117 116 111 105 116

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...