DirHotList.ahk :: Navigate Hotlist by Menu Position#

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

DirHotList.ahk :: Navigate Hotlist by Menu Position#

Post by *Balderstrom »

Inspired by this thread: Incremental search in Ctrl+D, which wanted something like TC's QuickSearch for the Dir HotList -- I figure it would be possible, but would require a lot more logic to parse the †menu output or the wincmd DirHotList section properly.

Here's an option that allows searching by the menu position number.

Create a User Command:
em_TCFavMenu
Command: "C:\Program Files\AutoHotKey\AutoHotKey.exe" "C:\Path\to\the\script\TC_DirHotList.ahk"
Create a ShortCut: Ctrl + D that is assigned to em_TCFavMenu

Usage:
KEYPAD KEYS:
+:: Select
. :: Select
- :: Left
/ :: Up
* :: Down
Enter :: Enter

Other KEYS:
/ or \ :: Select
Enter :: Enter
Left/Right/Up/Down ArrowKeys as Normal.
ESC :: ESC
  • Browse HotList with ArrowKeys and Enter(s) as usual.
  • Any letter input will be passed to the HotList menu and the script will exit.
  • When you enter a number, Press Enter or one of the "Select" Keys.
  • Pressing a "Select" Key twice in succession, is the same as Enter.
Example:
If your "Docs" is the 4th item in your DirMenu/FavMenu
  • --> Press: "4 Enter" to Open that Directory
  • --> 4+ (or 4. etc) to select the Menu
If your "Docs" is the 2nd item of the 2nd SubMenu
  • --> Press: "2 Enter 2 Enter" _OR_ "2+2++", OR 2+2 Enter, etc.
To Open a New Tab First:
  • Press any Select Key as the very First Key.
    e.g. +4+ OR .4.. OR +4 ENTER, etc
AHK Script: TC_DirHotList.ahk

Code: Select all

;;
;; Script: TC_DirHotList.ahk	v1.75
;; 
;; Author: Balderstrom, Sept.2010
;;
;; Usage: Browse TC's DirHotList by menu# position.
;;        Open a NewTab if NumpadADD DOT, ./ or \ is pressed before a Number.
;;
;;
   #SingleInstance, Force 
   #NoEnv 
SetBatchLines, -1

TC_DirHotList()
return


TC_DirHotList()
{
	GLOBAL GLOBAL_ERROR, CLICK_DOWN, GLOBAL_SEND

	WinWaitActive, ahk_class TTOTAL_CMD
	PostMessage, 0x433, 526, 0,, A		; cm_DirectoryHotlist
	WinWait, ahk_class #32768

	SetTimer, CheckERROR, 200
	FirstInput := TRUE

	iStrParseAgain:
	Input, iStr,,\+/.{NumpadDot}{NumpadAdd}{Enter}{NumpadEnter}{Escape}{Up}{NumpadDiv}{Down}{NumpadMult}{Left}{NumpadSub}{Right}
	RegExMatch(ErrorLevel, "EndKey:(.*)", rStr )
	
	if( rStr1 == "Escape" && GLOBAL_ERROR := "Escape" )
		return
	if( iStr && !RegExMatch(iStr, "^\d+$") && GLOBAL_ERROR := "ExitNow" && GLOBAL_SEND := iStr )
		return
	if( iStr )
	{
		PostMessage, 0x1ed, % iStr - 1
		FirstInput := FALSE
		CLICK_DOWN := TRUE
		iStrLast := iStr
	}
	if( rStr1 && RegExMatch(rStr1, "(\/|\\|\+|NumpadAdd|\.|NumPadDot)") && rStr1 := "" )
	{
		if( !FirstInput )
		{
			if( iStrLast && !(CLICK_DOWN:=FALSE) )
				PostMessage, 0x1ef, % iStrLast - 1
			else
				Send, {Enter}

			iStrLast := 0
		}
		else	;; If + . / or \ is the very first key.
		{		;; Then create a new Tab.
			SetTimer, CheckERROR, OFF
		
			Send, {Esc}
			WinWaitClose, ahk_class #32768
			Send, ^t	; New Tab
			PostMessage, 0x433, 526, 0,, A	; cm_DirectoryHotlist
			WinWait, ahk_class #32768
		
			SetTimer, CheckError, 200
		}
	}
	if( rStr1 )
	{
		rStr1 := ( rStr1 == "NumpadSub" ? "Left" : rStr1 == "NumpadDiv" ? "Up" : rStr1 == "NumpadMult" ? "Down" : rStr1 )

		if( iStrLast && !(CLICK_DOWN:=FALSE) )
			PostMessage, 0x1ef, % ( InStr(rStr1, "Enter") ? iStrLast : 0 ) - 1
		else
			Send, % "{" rStr1 "}"
		iStrLast:=0
	}
	FirstInput := FALSE
	
Goto, iStrParseAgain
}


CheckERROR:
	if( GLOBAL_ERROR == "ExitNow" )
		Goto, ExitApp
	if( GLOBAL_ERROR == "Escape"  )
	{
		SetTimer, CheckERROR, OFF
		Send, {Escape}
		ToolTip, % "TC_FavMenu :: Cancelled.",,,20
		Sleep, 1000
		Tooltip,,,,20
	}
	ifWinExist, ahk_class #32768
		return
ExitApp:
	Send, % ( GLOBAL_SEND ? GLOBAL_SEND : "" )
	if( CLICK_DOWN )
		PostMessage, 0x1ef, -1
ExitApp



† SideBar Note:
Menu Output (mentioned above), when you have SubMenu's

Code: Select all

0 : -1		AppData
0 : 16003		AppData
1 : 16004		OpSessions
2 : 16005		OpCache
1 : -1		$_APPS_$
0 : 16008		F_TCMD
1 : -1		1. Junk
0 : 16010		1. Test
1 : 16011		cm_Return
2 : 16014		exCMD
3 : 16015		isBin
4 : 16016		TWinKey
5 : 16017		FOO
6 : 16018		wdx
7 : 16019		emFoo
8 : 16020		_AUDIO_
9 : 0		---------------------------------------
10 : 16000		&Add current dir
11 : 16001		&Configure...
Last edited by Balderstrom on 2010-09-18, 16:08 UTC, edited 6 times in total.
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

A few usability fixes.
AND Changed any MessageBoxes to Non-interrupting Tooltips.

[Edit]
  • Final, Changed to TC_DirHotList.ahk
[/Edit]
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Added option to Open a New Tab before changing directories.
Example: +4+

Couple minor bug fixes.
Fixed Browsing with Arrow Keys at any time, not just prior to a Number input.
Added a few more NumPad keys, so the menu can be completely navigated with the Numpad only.


=============================================
@Moderators
Can you split my posts into the Plugins Board,
Title: DirHotList.ahk :: Navigate Hotlist by Menu Position#

Thanks.
User avatar
Hacker
Moderator
Moderator
Posts: 13065
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

[mod]Thread split from Incremental search in Ctrl+D.

Hacker (Moderator)[/mod]
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
Post Reply