AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Folder Menu

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Thu Jun 03, 2004 8:47 am    Post subject: Folder Menu Reply with quote

Here's a script that'll show a browsable folder structure (menu). the path to start from, is configurable.



Arrow click to browse, Shift + click to select.

It can have varied uses, what i've posted here is sort of a template to be used in scripts. by the way its very easy to make it show files too or just files or files of certain type (like *.lnk to show only shortcuts).

Code:

;___________________________________________
;____Folder Menu____________________________


; Select startup folder here
Dir = c:

; Clicking on the menu title takes you one folder out
MenuTitle = [..]


;___________________________________________


; Change script below only if you know what
; you're doing.

SetFormat, float, 0.0
SetBatchLines, 10ms


HotKey, *~LButton, MenuClick
HotKey, *~LButton, Off
MouseGetPos, fmX, fmY



ShowMenu:
   Menu = %MenuTitle%
   MenuItems =
   paths =
   Loop, %dir%\*.*, 2
      paths = %paths%`n%A_LoopFileFullPath%
   StringTrimLeft, paths, paths, 1
   sort, paths
   Loop, parse, paths, `n
   {
      StringGetPos, spos, A_LoopField, \, R
      spos ++
      StringTrimLeft, FileName, A_LoopField, %spos%
      MenuItem%A_Index% = %FileName%
      MenuItem%A_Index%path = %A_LoopField%
      MenuItems ++
      Menu = %Menu%`n%FileName%
   }
   HotKey, *~LButton, On
   Sleep, 100   ; a fix to display menu properly (thanx Chris)
   ToolTip, %Menu%, %fmX%, %fmY%
   WinActivate, %MenuTitle%
Return



MenuClick:
   GetKeyState, State, Shift

   HotKey, *~LButton, Off
    IfWinNotActive, %MenuTitle%
    {
       ToolTip
       ExitApp
    }
    CoordMode, Mouse, Relative
    MouseGetPos, mX, mY
    ToolTip
   mY -= 3      ;space after which first line starts
   mY /= 13   ;space taken by each line
   IfLess, mY, 0, ExitApp
   IfEqual, mY, 0
   {
      StringLen, Len, Dir
      StringGetPos, SPos, Dir, \, R
      Len -= %SPos%
      StringTrimRight, Dir, Dir, %Len%
      Goto, ShowMenu
   }
   IfGreater, mY, %MenuItems%, ExitApp

   StringTrimLeft, Dir, MenuItem%mY%path, 0
   
   IfEqual, State, D
   {
      StringTrimLeft, Dir, MenuItem%mY%path, 0
      msgbox, %DIR%
      ExitApp
   }
   
   GoSub, ShowMenu
Return

;___________________________________________

_________________


Last edited by Rajat on Thu Jun 10, 2004 7:13 am; edited 1 time in total
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Thu Jun 03, 2004 1:13 pm    Post subject: Reply with quote

I've tried that script and it's great. I'm planning a Sort command for the next release, which will allow the folders in a script like this to be sorted so that they're always alphabetical.
Back to top
View user's profile Send private message Send e-mail
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Thu Jun 03, 2004 7:14 pm    Post subject: Reply with quote

Quote:
I'm planning a Sort command for the next release

that'd b really nice!

will that b something like this:
loop, sort
{
}

i hope u're not planning to modify the loop, file to support sort as sorting will also benefit other commands.
_________________
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Thu Jun 03, 2004 9:17 pm    Post subject: Reply with quote

Quote:
will that b something like this:
loop, sort

No, I plan to have it sort the contents of a variable based on some delimiter (usually newline). Here are the design details:

Sort, VarName, Options
Options:
C Case sensitive
DLx Delimiter for line. If omitted, x defaults to `n, which allows lines terminted in CRLF or just LF to be sorted.
N Numerical sort (assume target column or field is a number)
P Position to start at (i.e. which column number)
R Reverse sort

More options are planned later, but the above are the primary ones. Ideas and improvements are welcome.
Back to top
View user's profile Send private message Send e-mail
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Fri Jun 04, 2004 7:43 am    Post subject: Reply with quote

yep... that sounds quite nice! ...i specially like the custom delimiter thing.
_________________
Back to top
View user's profile Send private message
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Thu Jun 10, 2004 7:12 am    Post subject: Reply with quote

it was tricky at first but now its done. the folder menu script now shows the folders in alphabetical order, using the new 'sort' command.
_________________
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Thu Jun 10, 2004 12:24 pm    Post subject: Reply with quote

Nice work, I'm glad you found a use for Sort. When I release today's version, maybe you can see if a popup menu will work better than your tooltip menu. The tooltip menu might be nicer for this purpose since the font is smaller, etc.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group