Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Folder Menu


  • Please log in to reply
6 replies to this topic
Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
Here's a script that'll show a browsable folder structure (menu). the path to start from, is configurable.

Posted Image

: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).

;___________________________________________
;____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

;___________________________________________

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
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.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004

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.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

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.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
yep... that sounds quite nice! ...i specially like the custom delimiter thing.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
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.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
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.