AutoHotkey Community

It is currently May 26th, 2012, 6:30 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: June 8th, 2009, 1:23 pm 
Offline

Joined: November 14th, 2007, 2:47 pm
Posts: 335
Location: London, England
Hey guys,

I am working on a script that will be able to move files to regularly used custom locations by right clicking. (like "Send To" but far more customisable and advanced.)

My question is this....

How do I get information about a file I have selected in Windows Explorer?

e.g I have selected the file I want to move... how do I return that info into ahk so it can move the file?

Cheers

J


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 8th, 2009, 1:45 pm 
Offline

Joined: March 24th, 2004, 2:34 pm
Posts: 299
What kind of info is it that you need?

Is it info needed to move the file? Or do you want supplementary info such as the file attributes? (like Read-Only, System or Archive)?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 8th, 2009, 1:47 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
Depending on you OS you can use a shell command from the registry.

For XP the key to add to is HKEY_CLASSES_ROOT\*\shell\[COMMAND NAME] (ie The name you want to see when you right click a file)\command
and the value will be "[drive]:\[complied script location]" %1. (Include the quotes if your system does not use 8.3)

%1 will represent the filename as a the variable %1% in the script. You can then do use a loop to convert the 8.3 format to the fullpath with A_LoopFileFullPath.

That should get you on your way ;).

hth

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Last edited by TLM on June 8th, 2009, 1:53 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 8th, 2009, 1:48 pm 
Offline

Joined: November 14th, 2007, 2:47 pm
Posts: 335
Location: London, England
JDN wrote:
What kind of info is it that you need?

Is it info needed to move the file? Or do you want supplementary info such as the file attributes? (like Read-Only, System or Archive)?


The main information needed is the file path, so that I can get that info into AHK so it can then perform the move to whichever directory is selected.

I've tried searching, but couldnt find anything. Although im sure its probably been discussed before.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 8th, 2009, 1:54 pm 
Offline

Joined: November 14th, 2007, 2:47 pm
Posts: 335
Location: London, England
TLM wrote:
Depending on you OS you can use a shell command from the registry.

For XP the key to add to is HKEY_CLASSES_ROOT\*\shell\[COMMAND NAME] (ie The name you want to see when you right click a file)\command
and the value will be "[drive]:\[complied script location]" %1. (Include the quotes if your system does not use 8.3)

%1 will represent the filename as a the variable %1% in the script. You can then do use a loop to convert the 8.3 format to the fullpath with A_LoopFileFullPath.

That should get you on your way ;).

hth


Thank you for the response.

I will give it a try. 8)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 8th, 2009, 2:18 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
Just to clarify. You 1st create a key in the registry by using:

Code:
RegWrite, REG_SZ, HKCR, *\shell\Display File Name\Command, , "%A_Desktop%\Displayname.exe" "`%1"


When you run this, you should be able to right click on any file and see "Display File Name" in the context menu. It will not work yet until you create the target script.

Next create the script:

Code:
msgbox, %1%
(Yes its just that line ;))

Save it to your desktop and then compile it to the name Displayname.exe (for this example).

Now when you right click a file and choose Display File Name, you should get a message box with the file name and location.

You can then adapt this to your liking.

Let me know if it works or if you need further instructions.

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 8th, 2009, 3:10 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
doyle wrote:
The main information needed is the file path, so that I can get that info into AHK so it can then perform the move to whichever directory is selected.
Read the CLIPBOARD doc
Quote:
Files (such as those copied from an open Explorer window with Control-C) are considered to be text: They are auto-converted to their filenames (with full path) whenever Clipboard is referenced in the script. To extract the files one by one ...
http://www.autohotkey.com/docs/misc/Clipboard.htm

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 8th, 2009, 3:30 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
Figured copy was too obvious.. :oops:

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 8th, 2009, 3:44 pm 
Offline

Joined: November 14th, 2007, 2:47 pm
Posts: 335
Location: London, England
TLM wrote:
Figured copy was too obvious.. :oops:


Same here. :lol:

Thank you both for your help.

I think I can probably get there now after this.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 8th, 2009, 3:55 pm 
Offline

Joined: November 14th, 2007, 2:47 pm
Posts: 335
Location: London, England
Is there an effective way of establishing whether the file copied is a file or a folder?

If its a folder i'll have to use FileMoveDir instead of FileMove.

Is using ErrorLevel the only way? (i.e if one fails do the other)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 8th, 2009, 3:57 pm 
use FileExist(FilePattern)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 8th, 2009, 4:15 pm 
Offline

Joined: November 14th, 2007, 2:47 pm
Posts: 335
Location: London, England
Z_Gecko wrote:
use FileExist(FilePattern)


Awesome! Thank You!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: rbrtryn, SKAN and 58 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group