Single command / button to toggle between two specific view modes possible?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
9kvD38n6
Junior Member
Junior Member
Posts: 89
Joined: 2010-09-03, 08:23 UTC

Single command / button to toggle between two specific view modes possible?

Post by *9kvD38n6 »

Can anyone see a way of using the same trigger (TC button / internal command, Autohotkey or whatever) to toggle the view mode for a file list between two fixed alternatives (complex default sort and simple sort by date). Toggling between the default view mode and a simple sort (as by clicking on a tab above the file list) would be fine, too.

The key point here is recognizing what view / sort state is active for the file list and then reliably switching to the alternative. If there was any way to determine the current view or sort mode via Autohotkey (even putting an indicator on the title bar or something like that), I could work with that.

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

Re: Single command / button to toggle between two specific view modes possible?

Post by *Horst.Epp »

I used a AHK script which toggles a view and stores the status in an ini file.
Its based on a script from Stefan.
This can be modified by creating another em_command.

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"
;  
;  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
myUserAHKini := RegExReplace(A_ScriptFullPath, "(ahk|exe)$", "ini")
; --------------------------------
; 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   #####################################

Windows 11 Home x64 Version 23H2 (OS Build 22631.3447)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
9kvD38n6
Junior Member
Junior Member
Posts: 89
Joined: 2010-09-03, 08:23 UTC

Re: Single command / button to toggle between two specific view modes possible?

Post by *9kvD38n6 »

Thanks for sharing your approach. Gets complicated when trying to keep track of two panes each in multiple instances. I have an idea that I might check the pixel colour on the Date tab to determine the state...
Post Reply