AutoHotkey: With Alt - \ always to root: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(changes in TC7.5pb3 (no more UnicodeClass, but TPathPanel1/2)) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 19: | Line 19: | ||
Here's a variant by '''ND''', which ensures that the script is only launched when one of the TC panels is active and which leaves the command-line history unmodified (tested in TC 5.50 and TC 7.01 on WinXP SP2) | Here's a variant by '''ND''', which ensures that the script is only launched when one of the TC panels is active and which leaves the command-line history unmodified (tested in TC 5.50 and TC 7.01 on WinXP SP2, and TC 7.5 on WinXP SP3) | ||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;! \brief pressing Alt+\\ should land in drive root rather than tab root | ;! \brief pressing Alt+\\ should land in drive root rather than tab root | ||
; | ; | ||
; Assumes that the | ; Assumes that the panel title-paths are accessible (TMyPanel5/TMyPanel9) | ||
; | ; | ||
; Computes the number of different parts separated by \\, | ; Computes the number of different parts separated by \\, | ||
Line 31: | Line 31: | ||
#IfWinActive, ahk_class TTOTAL_CMD | #IfWinActive, ahk_class TTOTAL_CMD | ||
~!\:: | ~!\:: | ||
WinGetActiveTitle, tcVersion ; Total Commander x.yy - UserName | |||
tcVersion := SubStr( tcVersion, 17, 3 ) | |||
If(( tcVersion is float ) and ( tcVersion >= 7.5 )) | |||
{ | |||
tcPathR = TPathPanel1 ; new in TC 7.5 | |||
tcPathL = TPathPanel2 | |||
} | |||
Else | |||
{ | |||
tcPathL = TMyPanel9 | |||
tcPathR = TMyPanel5 | |||
} | |||
; only when the actual TC panels are active | ; only when the actual TC panels are active | ||
ControlGetFocus, tcFocus | ControlGetFocus, tcFocus | ||
If( RegExMatch( tcFocus, "^ | If( RegExMatch( tcFocus, "^TMyListBox1$" ) ) | ||
tcPath = %tcPathL% | |||
ControlGetText, tcStatus, | Else | ||
If( RegExMatch( tcFocus, "^TMyListBox2$" ) ) | |||
tcPath = %tcPathR% | |||
Else | |||
Return | |||
ControlGetText, tcStatus, %tcPath% | |||
RegExReplace( tcStatus, "[^\\>]+", "$1", tcBack ) | |||
tcBack-- ; minus the drive root itself | |||
If( RegExMatch( tcStatus, "^.\\[^\\]" ) ) | |||
tcBack-- ; minus the server root for network drives | |||
If( tcBack > 0 ) | |||
Loop, %tcBack% | |||
PostMessage, 1075, 2002 ; cm_GoToParent | |||
Return | Return | ||
Line 51: | Line 70: | ||
{{translated|AutoHotkey: Mit ALT - \ ins Wurzelverzeichnis|AutoHotkey}} | {{translated|AutoHotkey: Mit ALT - \ ins Wurzelverzeichnis|AutoHotkey}} | ||
[[Category:AutoHotkey scripts|With Alt - \ always to root]] |
Latest revision as of 07:29, 18 May 2009
If you are working with 'softlocked' Tabs (locked but dir change allowed) it's most time useful to change with [Ctrl]+[\] to the root of the locked Tab instead root of the drive. You can achieve this with the key LockedGoToDriveRoot=0 in the wincmd.ini.
However, sometimes it is useful to go instead to the root of the drive. That's what this script is for:
;Alt \ leads to root of drive !\:: IfWinActive ahk_class TTOTAL_CMD { ; activate the command line PostMessage, 1075, 4003, , , ahk_class TTOTAL_CMD ; type cd \ sendraw, cd \ ; send it send, {ENTER} } return
Here's a variant by ND, which ensures that the script is only launched when one of the TC panels is active and which leaves the command-line history unmodified (tested in TC 5.50 and TC 7.01 on WinXP SP2, and TC 7.5 on WinXP SP3)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;! \brief pressing Alt+\\ should land in drive root rather than tab root ; ; Assumes that the panel title-paths are accessible (TMyPanel5/TMyPanel9) ; ; Computes the number of different parts separated by \\, ; then goes-up the appropriate number of parent dirs (cm_GoToParent) ; #IfWinActive, ahk_class TTOTAL_CMD ~!\:: WinGetActiveTitle, tcVersion ; Total Commander x.yy - UserName tcVersion := SubStr( tcVersion, 17, 3 ) If(( tcVersion is float ) and ( tcVersion >= 7.5 )) { tcPathR = TPathPanel1 ; new in TC 7.5 tcPathL = TPathPanel2 } Else { tcPathL = TMyPanel9 tcPathR = TMyPanel5 } ; only when the actual TC panels are active ControlGetFocus, tcFocus If( RegExMatch( tcFocus, "^TMyListBox1$" ) ) tcPath = %tcPathL% Else If( RegExMatch( tcFocus, "^TMyListBox2$" ) ) tcPath = %tcPathR% Else Return ControlGetText, tcStatus, %tcPath% RegExReplace( tcStatus, "[^\\>]+", "$1", tcBack ) tcBack-- ; minus the drive root itself If( RegExMatch( tcStatus, "^.\\[^\\]" ) ) tcBack-- ; minus the server root for network drives If( tcBack > 0 ) Loop, %tcBack% PostMessage, 1075, 2002 ; cm_GoToParent Return
Back to AutoHotkey