Disable Folders always on top

English support forum

Moderators: Hacker, petermad, Stefan2, white

User avatar
tuska
Power Member
Power Member
Posts: 4060
Joined: 2007-05-21, 12:17 UTC

Re: Disable Folders always on top

Post by *tuska »

7995 wrote: 2021-12-13, 15:48 UTC This is a separate button. Can i create a button which as a toggle has two commands: show/hide foiders?
Not that I am aware of.

The only possibility I see at the moment (untested) would be to create a View mode with Auto Switch Mode rules.
Then a filter would be switched on automatically and switched off again afterwards.
However, since switching off the filter might have an effect on the next View mode or the next view, I don't see that as expedient.

PS:
I don't know if that is an option for you...
In Everything 1.5 Alpha it is possible to create this sorting:
Menu "View" -> Sort by -> Mix Files and Folders


Windows 10 Pro (x64) Version 21H2 (OS build 19044.1387)
Overview: View Mode | Auto Switch Mode | Custom columns view
TC 10.00 x64/x86 | 'Everything' 1.5.0.1289a (x64)
Switching from Everything 1.4 to 1.5 | Search queries: TC <=> 'Everything'
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Disable Folders always on top

Post by *Stefan2 »

7995 wrote: 2021-12-13, 15:48 UTC This is a separate button. Can i create a button which as a toggle has two commands: show/hide foiders?
Since there is no internal command like cm_ShowFilesOnly we have to create a own UserDefinedCommand,

I named it "em_SrcNoFolders" and wrote it to my usercmd.ini
[em_SrcNoFolders]
cmd=cd |*\



With this both commands, em_SrcNoFolders and cm_SrcAllFiles we have two commands which we can use to toggle the view.
em_SrcNoFolders => show files only, do not show folders
cm_SrcAllFiles ===> show all files and folders



For to send that commands to TC, we need a tool which can execute SendMessage for both cm and em commands.
With the AutoHotkey.exe in the TC folder and a AHK-Script we can do that.



Here is a AHK-Script (AHK v1.1.xx) which works for me:
You can execute that script from a button, assign an keyboard shortcut to or add an alias for the TC command line. (see my sig)

myScript.ahk

Code: Select all

#SingleInstance force
; TOGGLE the view
; Stefan 2021-12-13 Mon 19:09:46
; Found at https://ghisler.ch/board/viewtopic.php?p=408256#p408256
;  
;  AutoHotkey script, execute like "AutoHotkey.exe myScript.ahk" (tested with AutoHotkey.exe 1.1.22.9 of 2015)
;  
;  1) create first a UserDefinedCommand in "usercmd.ini"
;  [em_SrcNoFolders]
;  cmd=cd |*\
;
;
; #############  script settings to do the wanted behaviour  ###################
; Create a userAHK.ini to store the current state:
EnvGet, CommPath, Commander_Path
myUserAHKini=%CommPath%\userAHK.ini             ;// ini file in TC main folder
;myUserAHKini:=SubStr(A_ScriptName, 1, -4) . ".ini" ;// ini file in folder with *.ahk file
; --------------------------------
; Set default and/or read the userAHK.ini
myViewFoldersONLYstate=0
IfExist, %myUserAHKini%
{ 
	;IniRead, OutputVar, Filename, Section, Key [, Default]
	IniRead, myViewFoldersONLYstate, %myUserAHKini%, Toggles, myViewFoldersONLY
}
; --------------------------------
; Execute an command based on the current state, stored in the userAHK.ini
If(myViewFoldersONLYstate=1)
{
	TC_SendData("cm_SrcAllFiles"                  , "EM")
	;  cm_SrcAllFiles=312;Source: All files ; see "TOTALCMD.INC" text file in TC-folder:
	IniWrite, 0, %myUserAHKini%, Toggles, myViewFoldersONLY 
}
Else
{
	TC_SendData("em_SrcNoFolders"       , "EM")
	;  create that command yourself in "usercmd.ini"
	;IniWrite, Value, Filename, Section, Key
  IniWrite, 1, %myUserAHKini%, Toggles, myViewFoldersONLY 
}
ExitApp
; --------------------------------
; #############   special code by artt , don't touch ###################
;//https://ghisler.ch/board/viewtopic.php?f=6&t=32658&start=30
;//New WM_COPYData Examples
;//artt	     Junior Member     Junior Member	     Posts: 39	     Joined: Sun May 03, 2009 9:03	 
TC_SendData(Cmd, CmdType="", msg="", hwnd="") {
   Critical   ; Define "OnMessage" as STATIC it is registered at Script startup.
   STATIC om:=OnMessage(0x4a, "TC_SendData"), TC_ReceiveDataValue:="", TC_DataReceived:=""	; 0x4a is WM_COPYDATA

   IF ((msg=0x4A) AND (hwnd=A_ScriptHwnd)) ; EnSure is trigered by this Script.
      EXIT (TC_ReceiveDataValue:=StrGet(NumGet(CmdType + A_PtrSize * 2)), TC_DataReceived:="1")

   VarSetCapacity(CopyDataStruct, A_PtrSize * 3), TC_ReceiveDataValue:=1, TC_DataReceived:=""
   IF CmdType IN LR,ST			; CD   Command
	DirType:=CmdType, CmdType:="CD"
   ELSE IF (CmdType="")			; Ask TC
	CmdType:=(A_IsUnicode ? "GW" : "GA"), TC_ReceiveDataValue:=""

   If( A_IsUnicode ) {
      VarSetCapacity( cmdA, StrPut(cmd, "cp0"),0) ; 3rd parameter "0" is necessary for CD "LeftPath only"
      Loop, % StrLen(cmd)
         NumPut( Asc(SubStr(cmd, A_Index, 1)), cmdA, A_Index - 1, "Char")
   }
   NumPut( Asc(SubStr(CmdType,1,1)) + 256 * Asc(SubStr(CmdType,2,1)), CopyDataStruct,0 )
   NumPut( StrLen(cmd) + (CmdType="CD" ? 5 : 0), CopyDataStruct, A_PtrSize )
   NumPut((A_IsUnicode ? &cmdA : &cmd), CopyDataStruct, A_PtrSize * 2)
   Loop, % (CmdType=="CD" ? 2 : 0)
      NumPut(Asc(SubStr(DirType,A_Index,1)), (A_IsUnicode ? cmdA : cmd), (StrLen(cmd)+A_Index),"Char")
   SendMessage, 0x4A,%A_ScriptHwnd%, &CopyDataStruct,, ahk_class TTOTAL_CMD

;IF you send a 'request' command to TC (all Ask TC commands: A, LP, LC, ...), script is waiting for (500 x 10 = 5000ms = 5 seconds) for TC to response/answer.
;If the answer arrives before the 5 seconds, it is immediately breaking the interaction and return the answer to the user (normally their is no delay).
   While (TC_ReceiveDataValue="") {
      IfEqual, TC_DataReceived,    1, Break
      IfGreaterOrEqual, A_Index, 500, Break
      Sleep,10
   }
   Return TC_ReceiveDataValue
}
; #############   EOF   #####################################





 
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6981
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Disable Folders always on top

Post by *Horst.Epp »

2Stefan2
I would not store the files in the TC home dir.
I use a scripts sub-dir for this.
No need for the AutoHotkey.exe in TC folder, just compile the script.

Change the definition of the ini-file location and it will be stored where the script is.
myUserAHKini := RegExReplace(A_ScriptFullPath, "(ahk|exe)$", "ini")
Windows 11 Home, Version 24H2 (OS Build 26100.4061)
TC 11.55 RC2 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.4 x64
User avatar
petermad
Power Member
Power Member
Posts: 16032
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Disable Folders always on top

Post by *petermad »

I would suggest to use a View Mode that autoruns *cm_GoToFirstFile and then set an Auto Switch Mode with that view for directories (D).

Then TC will automatically go to the first file when entering a new directory
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Post Reply