 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
compuboy_r
Joined: 04 May 2004 Posts: 68
|
Posted: Mon Sep 06, 2004 11:43 am Post subject: Directory Menu !!!! |
|
|
The following script will show all your directory in a Menu and SubDirectories as SubMenus.
When a user clocks on the item the file will run.
When a Big Folder is Given it takes some time to initialize the menus so Wait for a INITIALIZATION COMPLETE MESSAGE IN TRAYTIP
| Code: | SetBatchLines, 3000
;________CONFIG SECTION
rootdir = %temp% ;Change The Directory Path Here
updatealways = 0 ;Use 1 to update database always and 0 to disable automatic updating
htkey = ^1 ;Change this to your own hotkey to display menu ( currently it is Ctrl+1 )
;_________________DONOT CHANGE ANYTHING BELOW
Hotkey,%htkey%,showmenu
SetTimer,ini,500
TrayTip,DirMenu,Initializing,
ifnotexist %A_ScriptDir%\database.txt
gosub, createdatabase
Menu,DirMenu,add,%rootdir%,godir
Menu,DirMenu,disable,%rootdir%
Menu,DirMenu,add,-`:`:Open Directory`:`:-,godir
if updatealways = 1
gosub createdatabase
goto createmenu
CreateMenu:
Loop, Read, database.txt
{
isfile = 0
StringReplace,Line,A_LoopReadLine,%rootdir%\,
ifinstring Line,.
isfile = 1
if isfile = 0
{
StringGetPos,pos,Line,\,R
StringLeft,pardir,Line,%pos%
StringReplace,dir,Line,%pardir%,
StringReplace,dir,dir,\
Menu,%Line%,add,-`:`:Open Directory`:`:-,godir
if pardir =
pardir = DirMenu
Menu,%pardir%,add,%dir%,:%Line%
}
else
{
StringGetPos,pos,Line,\,R
StringLeft,pardir,Line,%pos%
StringReplace,file,Line,%pardir%,
StringReplace,file,file,\
if pardir =
pardir = DirMenu
Menu,%pardir%,add,%file%,go
}
}
SetTimer,ini,off
TrayTip
return
go:
if A_ThisMenu = DirMenu
run %rootdir%\%A_ThisMenuItem%
else
run %rootdir%\%A_ThisMenu%\%A_ThisMenuItem%
return
godir:
if A_ThisMenu = DirMenu
run %rootdir%
else
run %rootdir%\%A_ThisMenu%
return
createdatabase:
runwait, %comspec% /c dir /s /b /os /a:d "%rootdir%" > "%A_ScriptDir%\database.txt",,hide
runwait, %comspec% /c dir /s /b /os /a:-d "%rootdir%" >> "%A_ScriptDir%\database.txt",,hide
return
showmenu:
Menu,DirMenu,show
return
ini:
TrayTip,DirMenu,Initializing,30
return |
|
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Mon Sep 06, 2004 12:20 pm Post subject: |
|
|
Nice.
At first I was puzzled by why the TrayTip appeared for so long. Then I realized that my temp folder has over 15000 items in it (because it has all the cookies and MSIE cached files); and apparently, adding an item to a menu is a high overhead operation for the OS to do, so the script takes a very long time to build the menu in my case.
Edit: Moved previous addendum below new reply.
Last edited by Chris on Mon Sep 06, 2004 12:26 pm; edited 2 times in total |
|
| Back to top |
|
 |
compuboy_r
Joined: 04 May 2004 Posts: 68
|
Posted: Mon Sep 06, 2004 12:25 pm Post subject: |
|
|
Yes, Menu Generation Takes Time
I have implemented this in ControlAMP (CornerAmp) also.
See Here : www.compuboy.cjb.net
compuboy_r[/url] |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Mon Sep 06, 2004 12:26 pm Post subject: |
|
|
It seems like you could use a file-pattern loop to avoid the need for a temporary file. With SetBatchLines set to -1, such a loop would probably be faster because it avoids the I/O of writing the temp file and reading it back in. For example:
Loop, %temp%\*.*, 1, 1 ; Retrieve directories and files. Recurse into subfolders.
{
...
} |
|
| Back to top |
|
 |
compuboy_r
Joined: 04 May 2004 Posts: 68
|
Posted: Mon Sep 06, 2004 7:35 pm Post subject: |
|
|
Thanks Chris for the nice idea
Script Updated to work without database now
| Code: | SetBatchLines, 3000
;________CONFIG SECTION
rootdir = %temp% ;Change The Directory Path Here
updatealways = 0 ;Use 1 to update database always and 0 to disable automatic updating
htkey = ^1 ;Change this to your own hotkey to display menu ( currently it is Ctrl+1 )
;_________________DONOT CHANGE ANYTHING BELOW
Hotkey,%htkey%,showmenu
SetTimer,ini,500
TrayTip,DirMenu,Initializing,
Menu,DirMenu,add,%rootdir%,godir
Menu,DirMenu,disable,%rootdir%
Menu,DirMenu,add,-`:`:Open Directory`:`:-,godir
goto createmenu
CreateMenu:
Loop, %rootdir%\*.*, 2, 1
{
StringReplace,Line,A_LoopFileFullPath,%rootdir%\,
StringGetPos,pos,Line,\,R
StringLeft,pardir,Line,%pos%
StringReplace,dir,Line,%pardir%,
StringReplace,dir,dir,\
Menu,%Line%,add,-`:`:Open Directory`:`:-,godir
if pardir =
pardir = DirMenu
Menu,%pardir%,add,%dir%,:%Line%
}
Loop, %rootdir%\*.*, 0, 1
{
StringReplace,Line,A_LoopFileFullPath,%rootdir%\,
StringGetPos,pos,Line,\,R
StringLeft,pardir,Line,%pos%
StringReplace,file,Line,%pardir%,
StringReplace,file,file,\
if pardir =
pardir = DirMenu
Menu,%pardir%,add,%file%,go
}
SetTimer,ini,off
TrayTip
return
go:
if A_ThisMenu = DirMenu
run %rootdir%\%A_ThisMenuItem%
else
run %rootdir%\%A_ThisMenu%\%A_ThisMenuItem%
return
godir:
if A_ThisMenu = DirMenu
run %rootdir%
else
run %rootdir%\%A_ThisMenu%
return
showmenu:
Menu,DirMenu,show
return
ini:
TrayTip,DirMenu,Initializing,30
return |
|
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Mon Sep 20, 2004 3:18 pm Post subject: |
|
|
| Quote: | At first I was puzzled by why the TrayTip appeared for so long. Then I realized that my temp folder has over 15000 items in it
Yes, Menu Generation Takes Time | I've applied a couple changes that should help with scripts such as the one above:
1) Increased maximum length of menu names and menu items names from 100 to 260. In addition, menus should use slightly less memory now.
2) Improved the speed of the "Menu Add" command: Scripts whose menus collectively contain thousands of items should now be able to create new menu items at least 100 times faster. |
|
| Back to top |
|
 |
compuboy_r
Joined: 04 May 2004 Posts: 68
|
Posted: Mon Sep 20, 2004 6:50 pm Post subject: |
|
|
Ultra COOL
Chris Thanks a lot for this wonderful change.
My Script that took 59 Secs to Make menu now makes it on the fly.
Its at least 100000000000000000000000 Times Faster now
compuboy_r |
|
| Back to top |
|
 |
jack
Joined: 04 Sep 2004 Posts: 77 Location: UK
|
Posted: Mon Sep 20, 2004 7:42 pm Post subject: |
|
|
it's nice.
however, when i list a folder that has a lot of files in it the scrolling is rather slow. and in some folders with hundreds of files i'd have to scroll a long way.
is it possible to chunk the files so that you could keep moving sideways?
or perhaps type a letter to shift to files beginning with that letter?
or some better idea i haven't thought of?
jack |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Mon Sep 20, 2004 7:56 pm Post subject: |
|
|
| I was hoping it would help; thanks for the feedback. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Mon Sep 20, 2004 8:00 pm Post subject: |
|
|
| Quote: | | when i list a folder that has a lot of files in it the scrolling is rather slow. and in some folders with hundreds of files i'd have to scroll a long way. | Let me know if that slowness just happened with the recent changes (in case I broke something). Anyway, there is an item on the to-do list to support dividing the menu into columns. That should reduce the amount of scrolling needed.
| Quote: | | is it possible to chunk the files so that you could keep moving sideways? | Hopefully the columns idea mentioned above covers this, but maybe you had something else in mind.
| Quote: | | or perhaps type a letter to shift to files beginning with that letter? | You might be able to do this already by putting ampersand characters in front of more than one choice that begins with the same letter. For example, if two items begin with Z and both have an ampersand, typing Z should jump to the first item rather than launching it. |
|
| Back to top |
|
 |
jack
Joined: 04 Sep 2004 Posts: 77 Location: UK
|
Posted: Mon Sep 20, 2004 9:28 pm Post subject: |
|
|
| Quote: | Let me know if that slowness just happened with the recent changes (in case I broke something). Anyway, there is an item on the to-do list to support dividing the menu into columns. That should reduce the amount of scrolling needed.
Quote:
is it possible to chunk the files so that you could keep moving sideways?
Hopefully the columns idea mentioned above covers this, but maybe you had something else in mind.
|
no, i don't think the scrolling speed has changed. but it's not rapid. and even if it was rapid, i don't think it's good UI to scroll hundreds of rows.
dividing the menu into columns would probably do it, yes. what happens if the columns don't fit on the screen... :)
thanks
jack |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Tue Sep 21, 2004 2:29 am Post subject: |
|
|
| Quote: | | what happens if the columns don't fit on the screen | I'm not sure, but since columns are a built-in OS feature for menus, it probably adds the scrolling back in. |
|
| Back to top |
|
 |
jack
Joined: 04 Sep 2004 Posts: 77 Location: UK
|
Posted: Tue Sep 21, 2004 5:53 am Post subject: |
|
|
maybe it would be possible to get a list of filetypes, rather than files, then select a filetype to see just those files.
jack |
|
| Back to top |
|
 |
jack
Joined: 04 Sep 2004 Posts: 77 Location: UK
|
Posted: Tue Sep 21, 2004 6:55 am Post subject: |
|
|
i see it is possible (at least on XP) to type a letter to go to files beginning with that letter.
jack
The English may not always be the best writers in the world, but they are incomparably the best dull writers |
|
| Back to top |
|
 |
soggos
Joined: 27 Mar 2008 Posts: 37 Location: France
|
Posted: Thu Apr 03, 2008 8:44 pm Post subject: but how to keep the alphabetical classification ?? |
|
|
Very koool,
bravo for the seconde version;
but in the first it was easy to keep the alphabetical classification (with cmd argument like /OS or /ON)
| Quote: | runwait, %comspec% /c dir /s /b /os /a:d "%rootdir%" > "%A_ScriptDir%\database.txt",,hide
runwait, %comspec% /c dir /s /b /os /a:-d "%rootdir%" >> "%A_ScriptDir%\database.txt",,hide |
but how to keep the alphabetical classification with the second version??
who know?
(sorry but i am a novice) |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|