LOADLIST sort order if invoked from Auto switch mode

Bug reports will be moved here when the described bug has been fixed

Moderators: white, Hacker, petermad, Stefan2

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

LOADLIST sort order if invoked from Auto switch mode

Post by *Horst.Epp »

The LOADLIST command normaly shows entries from a loaded list in the sort order of the loaded file.
So when the file contains a mix of files and dirs they are shown in this order.
If this command is part of an View mode, using an Auto-run command to start LOADLIST <filename>,
it displays the list with dirs on top if there is an Auto switch rule active for the dir of the file to be loaded.
This happens even when the sort order for this View mode is set to Unsorted or Unchanged.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: LOADLIST sort order if invoked from Auto switch mode

Post by *ghisler(Author) »

Not confirmed. I have
1. Defined an internal command em_listfile2 containing
LOADLIST c:\path\filelist.txt
with a directory after the files.
2. Defined a view mode which calls em_listfile2 in "Auto-run commands"
3. Defined a rule for a test directory

When I enter the directory, filelist.txt is loaded in changed form, with the dir where it was defined.
Even when I set a sort order in the view mode, it is set in the header but ignored for the file list.

Please provide more details.
Author of Total Commander
https://www.ghisler.com
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: LOADLIST sort order if invoked from Auto switch mode

Post by *Horst.Epp »

Thats what I make in our Everything GUI to TC AHK script.

After the results file from Everything is written the following command is executed:
Totalcmd64.exe /O /T /S C:\Tools\Wincmd\Scripts\Results\Everything.txt
Please note that the file format is UTF-16 with BOM.

There is a Auto switch mode which says:
4_rules=+C:\Tools\Wincmd\Scripts\Results\
4_mode=4
which sets the view to LoadEvResult.

View mode LoadEvResult sets the columns view to Search Results and
Auto-runs em_LoadEvResult

The em_command is:

Code: Select all

[em_LoadEvResult]
cmd=LOADLIST
param=C:\Tools\Wincmd\Scripts\Results\Everything.txt
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: LOADLIST sort order if invoked from Auto switch mode

Post by *Horst.Epp »

While testing I found the reason for the unwanted display of dirs on top.
The View mode LoadEvResult sets a columns view like search results after Feed to listbox.
If I set the Columns view to Unchanged the list of files and dirs is shown as in the file.
The problem is that a columns view should not force the Loadlist command to change the order of displayed items.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: LOADLIST sort order if invoked from Auto switch mode

Post by *ghisler(Author) »

I see - it does that because it has to use one of the columns for sorting, which can be a problem when switching between multiple custom columns views. I don't think that this can be avoided.
Author of Total Commander
https://www.ghisler.com
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: LOADLIST sort order if invoked from Auto switch mode

Post by *Horst.Epp »

Its not a big problem I normaly prefer to have dirs on top.
Only by testing a solution for the request of merged files and dirs in onother thread
I found this different behaviour.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: LOADLIST sort order if invoked from Auto switch mode

Post by *Horst.Epp »

With the new 10.52RC1 all problems are gone :D
Now the sorting order of the Everything results are preserved.
Our script scenario is much simpler now.
I now use the command line option LOADLIST: in the script to display the results
and I could remove the Auto-run command from the LoadEvResult view mode.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: LOADLIST sort order if invoked from Auto switch mode

Post by *ghisler(Author) »

Please let me know immediately if/when you find any problems!
Author of Total Commander
https://www.ghisler.com
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Re: LOADLIST sort order if invoked from Auto switch mode

Post by *tuska »

Horst.Epp wrote: 2022-10-04, 18:18 UTC With the new 10.52RC1 all problems are gone :D
Now the sorting order of the Everything results are preserved.
Our script scenario is much simpler now.
I now use the command line option LOADLIST: in the script to display the results
and I could remove the Auto-run command from the LoadEvResult view mode.
When using the new AHK script, the View mode with Auto Switch Mode is no longer necessary and the sorting is preserved in TC,
but this leads to this unpleasant side effect:
The content of field "Auto-run commands:" is no longer taken into account, e.g. cm_ExchangeSelBoth, etc. :?

I use cm_ExchangeSelBoth, for example, to automatically display the number of files and folders in the footer of Total Commander
after the search result has been transferred from 'Everything' to Total Commander.
I use it to check whether the search result in 'Everything' has arrived completely in Total Commander.
See also -> 13. 2.e OPTIONAL - Display (Objects, folders, files) in footer of 'Everything' 1.5


Ultimately, two AHK script variants with different approaches are now available. :)
Transfer 'Everything' GUI results to Total Commander - STEP-BY-STEP GUIDE, summary -> will be adapted...
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Re: LOADLIST sort order if invoked from Auto switch mode

Post by *tuska »

2Horst.Epp
I have now noticed a different problem when using the new AHK script: cm_ExchangeSelBoth

- View Mode and Auto Switch Mode -> OFF (as I also use the previous AHK script in addition).
- Everything 1.5: Sort by -> Mix Files and Folders | "D:\Daten\Programme\WinWord\" 27 objects (25 files, 2 folders)
- Button: %COMMANDER_PATH%\...\SEND_EV-RESULTS_to_TC-panel_(A)_CloseEverything-0_TAB-Search_result_(A).exe (new AHK-script!)
- The search result is displayed properly sorted in TC on tab "Search result:".
- Button: cm_ExchangeSelBoth -> 5 914 206 b / 5 914 206 b in 25 / 25 file(s) -> although additional 2 folders are visible!

I.e. the button with command: cm_ExchangeSelBoth does not work properly in this case!

Button with command: %COMMANDER_EXE% /O /T /S LOADLIST:C:\totalcmd\EV-Results\EV-Results.txt
also displays the search result properly sorted in TC on tab "Search Result:".
Button: cm_ExchangeSelBoth -> 5 914 206 b / 5 914 206 b in 25 / 25 file(s) -> although additional 2 folders are visible!.

Can you confirm this?

If I use the "previous" AHK script and the auto-run command "cm_ExchangeSelBoth" is automatically executed,
then the footer of Total Commander and Everything are identical. *)

*) EDIT:
It worked for a while, but now only 25 files are displayed in the footer of TC.
A PC cold start was carried out. Mmmh.
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Re: LOADLIST sort order if invoked from Auto switch mode

Post by *tuska »

- TC_clean_10.52RC1_x64.ini
- Button with command: %COMMANDER_EXE% /O /T /S LOADLIST:C:\totalcmd\EV-Results\EV-Results.txt -> 27 objects (25 files, 2 folders)
- Press button with command: cm_ExchangeSelBoth
- Result: 25 file(s)

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

Re: LOADLIST sort order if invoked from Auto switch mode

Post by *Horst.Epp »

tuska wrote: 2022-10-05, 11:09 UTC - TC_clean_10.52RC1_x64.ini
- Button with command: %COMMANDER_EXE% /O /T /S LOADLIST:C:\totalcmd\EV-Results\EV-Results.txt -> 27 objects (25 files, 2 folders)
- Press button with command: cm_ExchangeSelBoth
- Result: 25 file(s)

Please check.
Here the results match and are ok.
57 files and 4 dirs are shown after cm_ExchangeSelBoth and the same numbers are in the file from Everything.
This is regardless of the view mode.

Using the old or new script doesn't matter here !
The previous problems came from the usage of an Auto-run command in the view mode.
This is no longer needed as the new script start the Loadlist with the TC command line.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
nsp
Power Member
Power Member
Posts: 1804
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: LOADLIST sort order if invoked from Auto switch mode

Post by *nsp »

Using this command do not fix all.
You can still have an issue if you have custom column with sort on it. (not name, ext, date, size)
cm_SrcUnsorted do not remember original list order and place folder unmixed on top.
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Re: LOADLIST sort order if invoked from Auto switch mode

Post by *tuska »

Horst.Epp wrote: 2022-10-05, 11:20 UTC Here the results match and are ok.
57 files and 4 dirs are shown after cm_ExchangeSelBoth and the same numbers are in the file from Everything.
This is regardless of the view mode.

Using the old or new script doesn't matter here !
The previous problems came from the usage of an Auto-run command in the view mode.
This is no longer needed as the new script start the Loadlist with the TC command line.
I understand/know all that in principle.
At the moment I only have problems with the cm_ExchangeSelBoth <=> LOADLIST command.
I will check this further.
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Re: LOADLIST sort order if invoked from Auto switch mode

Post by *tuska »

I still think there is an error here: LOADLIST <=> cm_ExchangeSelBoth,
i.e. only the number of files is displayed in the TC footer.

New tests carried out with TC 10.52RC1 - after upgrade on 5.10.2022 to:
Windows 11 Pro (x64) Version 22H2 (OS build 22621.608)
EV-Results.txt (25 files, 2 folders) - Everything 1.5.0.1321a (x64)

Code: Select all

D:\Daten\Programme\WinWord\_2016-02-20_EINSTELLUNG-für-alte-Word-Dokumente.png
D:\Daten\Programme\WinWord\Appdata\
D:\Daten\Programme\WinWord\Built-In Building Blocks.dotx
D:\Daten\Programme\WinWord\Built-In Building Blocks.LNK
D:\Daten\Programme\WinWord\Built-In Building Blocks_15.LNK
D:\Daten\Programme\WinWord\descript.ion
D:\Daten\Programme\WinWord\FineReader7.dot
D:\Daten\Programme\WinWord\Appdata\Laufwerk-C_Templates.lnk
D:\Daten\Programme\WinWord\Normal.dot
D:\Daten\Programme\WinWord\Normal.dotm
D:\Daten\Programme\WinWord\Appdata\Normal.dotm
D:\Daten\Programme\WinWord\Normal.lnk
D:\Daten\Programme\WinWord\NormalEmail.dotm
D:\Daten\Programme\WinWord\Appdata\NormalEmail.dotm
D:\Daten\Programme\WinWord\pcwFileAndStyle.dot
D:\Daten\Programme\WinWord\pcwTextmarken-ori.dot
D:\Daten\Programme\WinWord\pcwTextmarken.dot
D:\Daten\Programme\WinWord\PDF-Converter-Prof7-Vorlage.dot
D:\Daten\Programme\WinWord\Sicherungskopie von Normal.wbk
D:\Daten\Programme\WinWord\Sicherungskopie von pcwTextmarken-ori.wbk
D:\Daten\Programme\WinWord\Sicherungskopie von pcwTextmarken.wbk
D:\Daten\Programme\WinWord\Textmarker\
D:\Daten\Programme\WinWord\Textmarker\Textmarker.dot
D:\Daten\Programme\WinWord\Textmarker\Textmarker.exe
D:\Daten\Programme\WinWord\Textmarker\Textmarker.pdf
D:\Daten\Programme\WinWord\Vorlage1.dot
D:\Daten\Programme\WinWord\Word-Anpassungen.exportedUI
SEND_EV-RESULTS_to_TC-panel_(A)_CloseEverything-0_TAB-Search_result_(A).AHK (compiled to .exe)

Code: Select all

Line 164: Run %TotalCmd% /O /T /S LOADLIST:%DestinationFile%

Code: Select all

SEND_EV-RESULTS_to_TC-panel_(A)_CloseEverything-0_TAB-Search_result_(A).AHK compiled to:
SEND_EV-RESULTS_to_TC-panel_(A)_CloseEverything-0_TAB-Search_result_(A).exe

Code: Select all

; Transfer Everything GUI results to TC
; Authors: Horst.Epp & Ovg
; Last modified: 04.10.2022 (Updated for TC 10.52 RC1)

; https://www.ghisler.ch/board/viewtopic.php?t=75439 ...... Open Everything GUI results with TC LOADLIST
; https://www.ghisler.ch/board/viewtopic.php?t=75417 ...... LOADLIST command and UTF8 file lists
; https://www.voidtools.com/forum/viewtopic.php?f=4&t=10594 Send ResultsList to Total Commander

; Build AutoHotkey_L
; Build x64
; Build Kill=true
; Build Zip=false
; Build Run=true

#NoEnv
;#Persistent
#SingleInstance Force
SetBatchLines, -1

; Create / read .ini file settings
SetTitleMatchMode, RegEx
iniFile := RegExReplace(A_ScriptFullPath, "(ahk|exe)$", "ini")

if not (FileExist(iniFile)) {
    iniContent :="
    (( LTrim
        [General]
	; DestinationFile
        ;    Where to save the output (full path to DestinationFile.txt)
        ; EverythingColumnPositions (Default: 2,1)
	;    The columns 'Name' and 'Path' must be visible in the Everything GUI Window
        ;    The first value is the position of the 'Path' column
        ;    The second value is the position of the 'Name' column
	; CloseEverything (Default 1 for yes)
	;    Should Everything GUI window be closed after transfering to TC
	; UseInstance (Empty for default instance)
        ;    Name of the Everything instance to be used for closing the GUI

; The contents of the following lines must be adjusted if necessary, e.g. path and parameter adjustments.
;********************************************************************************************************
        DestinationFile = C:\totalcmd\EV-Results\EV-Results.txt
        EverythingColumnPositions=2,1
        AddEndSlash = 1
        CloseEverything = 0
        UseInstance =
        Everything = C:\Everything\Everything64.exe
        TotalCmd = C:\totalcmd\TOTALCMD64.EXE
;********************************************************************************************************

    )"
    FileAppend, % iniContent, % iniFile, UTF-16
}
IniRead, DestinationFile, % iniFile, General, DestinationFile, %A_Space%
IniRead, EverythingColumnPositions, % iniFile, General, EverythingColumnPositions, 2`,1

IniRead, AddEndSlash, % iniFile, General, AddEndSlash, 1
IniWrite, %AddEndSlash%, % iniFile, General, AddEndSlash
IniRead, CloseEverything, % iniFile, General, CloseEverything, 1
IniWrite, %CloseEverything%, % iniFile, General, CloseEverything
IniRead, UseInstance, % iniFile, General, UseInstance, %A_Space%
IniWrite, %UseInstance%, % iniFile, General, UseInstance

IniRead, Everything, % iniFile, General, Everything, "C:\Everything\Everything64.exe"
IniRead, TotalCmd, % iniFile, General, TotalCmd, "C:\totalcmd\TOTALCMD64.EXE"

DestinationFile           := ResolveEnvVars(DestinationFile)
EverythingColumnPositions := StrReplace(EverythingColumnPositions, " ")

; Force error if none is given (or path doesn't exist)
SplitPath, DestinationFile, , dstPath
if (DestinationFile = "" || !InStr(FileExist(dstPath), "D")) {
    Msgbox, 16, Fatal error, Destination file definition is missing or illegal named !
    Return
}
if (EverythingColumnPositions = "" || !InStr(EverythingColumnPositions, ",")) {
    EverythingColumnPositions := "2,1"
}

columnArray := StrSplit(EverythingColumnPositions, ",")

hWnd := WinExist("ahk_exe Everything(?:\d\d)*\.exe")

if hWnd
{
  ControlGet, winContent, List, , SysListView321, % "ahk_id" hWnd

  if (winContent)
  {
    fullContent := ""
;   Loop over row(s)
    Loop, Parse, winContent, `n
    {
      rowID := A_Index
      path  := ""
      name  := ""
      full  := ""
      Bad := 2
;     Loop over column(s)
      Loop, Parse, A_LoopField, % A_Tab
      {
        colID   := A_Index
        content := A_LoopField
        If (colID > columnArray[1] And colID > columnArray[2])
        {
          Break
        }
        Else
        {
          If (colID = columnArray[1])
          {
;	    If !RegExMatch(content,"i)^[a-z]:|\\\.*?\\")
	    If !RegExMatch(content,"i)^(?:[a-z]:|\\\.*?\\)")
            {
              Break
            }
            path := content
            Bad -= 1
            If !RegExMatch(path,"\\$")
            {
              path := path . "\"
            }
          }
          Else if (colID = columnArray[2])
          {
            If content is Space
            {
              Break
            }
            name := content
            Bad -= 1
          }
        }
      }
      If (Bad == 0)
      {
        full        := path . name
        If InStr(FileExist(full), "D")
        {
          if (AddEndSlash == 1)
          {
            if !RegExMatch(full,"\\$")
            {
              full := full . "\"
            }
          }
          Else
          {
            If RegExMatch(full,"\\$")
            {
              full := SubStr(full,1,StrLen(full)-1)
            }
          }
        }
        fullContent .= full "`n"
      }
    }
    fullContent := RegExReplace(fullContent,"\R$","")
    If (FileExist(DestinationFile))
      FileDelete, % DestinationFile

        FileAppend, % fullContent, % DestinationFile, UTF-16

	DestinationDir := SubStr(DestinationFile,1,InStr(DestinationFile, "\",,-1))
	Run %TotalCmd% /O /T /S LOADLIST:%DestinationFile%
	If (CloseEverything) {
             run %Everything% -instance "%UseInstance%" -close
	}
    }
    Else
;   Empty search result
    {
      Msgbox, 16,, Search result is Empty, Nothing to do ...
    }
; No Everything window visible
} Else {
    Msgbox, 16, Fatal error, Everything window does not exist!
}
SetTitleMatchMode, 1
return

; ==================================
; = GOTO: FUNCTIONS - ResolveEnvVars
; ==================================
; http://www.autohotkey.com/board/topic/40115-func-envvars-replace-environment-variables-in-text/#entry310601
ResolveEnvVars(str) {
    if sz := DllCall("ExpandEnvironmentStrings", "uint", &str, "uint", 0, "uint", 0)
    {
        VarSetCapacity(dst, A_IsUnicode ? sz * 2 : sz)
        if DllCall("ExpandEnvironmentStrings", "uint", &str, "str", dst, "uint", sz)
            return dst
    }
    return str
}
SEND_EV-RESULTS_to_TC-panel_(A)_CloseEverything-0_TAB-Search_result_(A).ini

Code: Select all

[General]
; DestinationFile
;    Where to save the output (full path to DestinationFile.txt)
; EverythingColumnPositions (Default: 2,1)
;    The columns 'Name' and 'Path' must be visible in the Everything GUI Window
;    The first value is the position of the 'Path' column
;    The second value is the position of the 'Name' column
; CloseEverything (Default 1 for yes)
;    Should Everything GUI window be closed after transfering to TC
; UseInstance (Empty for default instance)
;    Name of the Everything instance to be used for closing the GUI

; The contents of the following lines must be adjusted if necessary, e.g. path and parameter adjustments.
;********************************************************************************************************
DestinationFile = C:\totalcmd\EV-Results\EV-Results.txt
EverythingColumnPositions=2,1
AddEndSlash =1
CloseEverything =0
UseInstance =
Everything = C:\Everything\Everything64.exe
TotalCmd = C:\totalcmd\TOTALCMD64.EXE
;********************************************************************************************************
Post Reply