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

Re: LOADLIST sort order if invoked from Auto switch mode

Post by *Horst.Epp »

tuska wrote: 2022-10-10, 23:56 UTC 2Horst.Epp
For your information:
Only a View mode and NO Auto Switch Mode is required (appropriate parameterization in the "Auto-run commands" field provided).
This applies at least to the examples given here.
Not agreed.
Without Auto Switch there is no control what view and sort is applied by just using a Loadlist in the script.
In your setup you get a simple list of files and dirs after the script start Loadlist.
This list is in the sort order from the Everything results, but I don't like the layout of this simple list
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
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 »

ghisler(Author) wrote: 2022-10-11, 07:23 UTC
When using a View mode with integrated Custom columns view (!), the SORTING problem still occurs
Unfortunately switching to custom columns forces a re-sort. ...
Maybe I can handle it as a special case only for a view mode where the sort order is set to "unchanged".
If that were possible, I would very much welcome it.
Horst.Epp wrote: 2022-10-11, 08:46 UTC
tuska wrote: 2022-10-10, 23:56 UTC 2Horst.Epp
For your information:
Only a View mode and NO Auto Switch Mode is required ...
This applies at least to the examples given here.
Not agreed.
Without Auto Switch there is no control what view and sort is applied by just using a Loadlist in the script.
In your setup you get a simple list of files and dirs after the script start Loadlist.
This list is in the sort order from the Everything results, but I don't like the layout of this simple list
You have provided your image here,
which you call "Branch View" (View mode + Custom columns view + Auto Switch Mode).
I can't see any special sorting in the picture.
In principle, I have also created such a view (View mode + Custom columns view).

As already mentioned here, I could not understand your variant with the Auto Switch Mode.
I still can't, despite a few more attempts.

Please give a detailed description again (without sections in wincmd.ini)
with all details of the fields of the View mode + integrated Custom columns view + Auto Switch Mode
here in the forum (or in the other forum).
The details should be similar to what I gave above in my detailed description of my View mode.

If for some reason it is not possible for you or if I do not understand these instructions again,
then I hereby end my tests, because I do not want to invest more time in this topic.

I need this function (transfer of MULTIPLE files/folders) only with max. 1% and the buttons I use
are enough for me. I use 99% for open of individual folders from Everything in Total Commander
and for this activity I do not need an AHK script.

Thanks.
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 »

I'll stop here :)
Personaly I like the sorting of dirs on top and have set sort_mix=0 in Everything.
Lets wait if Christian changes the sorting behaviour for custom views in future versions.
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
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-11, 18:08 UTC I'll stop here :)
OK, I will also stop here :?

Then you too may answer someone's question as to what exactly you mean by this -
if anyone asks this question at all (to my knowledge there has not been a request yet):
Horst.Epp wrote: 2021-10-10, 17:58 UTC 2. Create an Auto Switch mode which triggers when the dir from step 1 is opened
and sets the View mode "Branch View"
:mrgreen:
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-11, 19:14 UTC Then you too may answer someone's question as to what exactly you mean by this -
if anyone asks this question at all (to my knowledge there has not been a request yet):
Horst.Epp wrote: 2021-10-10, 17:58 UTC 2. Create an Auto Switch mode which triggers when the dir from step 1 is opened
and sets the View mode "Branch View"
:mrgreen:
Thats necessary to automatically get a certain view mode
after the Loadlist command shows the Everything results file.
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) »

OK, I have changed it now for when a view mode is applied (manually or automatically) where the sort order is set to "unchanged".
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 »

ghisler(Author) wrote: 2022-10-12, 07:49 UTC OK, I have changed it now for when a view mode is applied (manually or automatically) where the sort order is set to "unchanged".
Nice, so we wait on RC3 or the final :D
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 »

2Christian
Thanks for implementing it in RC3.
Works fine now with mixed lists from Everything.
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 »

2Tuska
With RC3 it works perfect as long as you have a view like my Branch view
which has the Sort order "Unchanged".
Thats exactly what Christian made with RC3.
The version of the Everything script doesn't matter here.
Note that the view should have "*|cm_SrcViewMode0" as Auto-run command
to get a normal view after leaving the results.
This also works fine for any later reuse of the results by a button with Loadlist.
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
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 »

2ghisler(Author)
ghisler(Author) wrote: 2022-10-12, 07:49 UTC OK, I have changed it now for when a view mode is applied (manually or automatically) where the sort order is set to "unchanged".
HISTORY.TXT wrote: 14.10.22 Release Total Commander 10.52 release candidate 3 (RC3)
12.10.22 Fixed: Keep sort order of list loaded via LOADLIST when switching to a view mode with sort order set to "unchanged" (32/64)
Thanks a lot for this implementation!  :)
Under the following test scenario, everything now works perfectly!

@Horst.Epp
Thanks!
I am now doing well without Auto-run command: |cm_SrcViewMode0 (Comment 3.).

Code: Select all

0 Everything 1.5.0.1323a (x64) ......................................... Menu "View" > Sort by > Mix Files and Folders: Yes/No
------------------------------------------------------------------------------------------------------------------------------
  Script 04.10.22 | VM * | Col.view: with/without | ASM ** | cm_-Command | LOADLIST | TC-SORT | TC-Footer | EV> Mix F&F: Y / N
1 - Button 1	  |  x   |   	       x    –     |   –    |     x  **** |    OK    |     OK  |    OK     |     ***      x   –
2 - Button 1	  |  x   |   	       x    –     |   –    |     –       |    OK    |     OK  |    OK     |              –   x
3 - Button 2	  |  x   |             –    x     |   –    |     x  **** |    OK    |     OK  |    OK     |              x   –
4 - Button 2	  |  x   |             –    x     |   –    |     –       |    OK    |     OK  |    OK     |              –   x
------------------------------------------------------------------------------------------------------------------------------

Code: Select all

  Script 21.10.21 | VM * | Col.view: with/without | ASM ** | cm_-Command | LOADLIST | TC-SORT | TC-Footer | EV> Mix F&F: Y / N
5 - Button 3	  |  x   |     	       x    –     |   –    |     –       |    OK    |     OK  |    OK     |              x   –
6 - Button 3	  |  x   |     	       x    –     |   –    |     –       |    OK    |     OK  |    OK     |              –   x
------------------------------------------------------------------------------------------------------------------------------
7 %COMMANDER_EXE% /O /T /S LOADLIST:C:\totalcmd\EV-Results\EV-Results.txt: OK
------------------------------------------------------------------------------------------------------------------------------
     * VM = View Mode
    ** ASM = Auto Switch Mode
   *** Everything > Mix Files and Folders
  **** cm_ - Commands
8      ..... cm_ExchangeSelBoth		3321	Invert selection (files+folders):  OK  	<--  <Default> for my purposes
9      ..... cm_ExchangeSelFiles	3322	Invert selection (files) .......:  OK
0      ..... cm_ExchangeSelFolders	3323	Invert selection (folders) .....:  OK
 
Detailed description of the SETTINGS used.
Button 1, Button 2   - View Mode + Custom colums view / AHK script 04.10.22
IMPORTANT: It is necessary to SWITCH OFF the 'Auto Switch Mode' and perform a TC Restart before each test.
Hints .: Before executing the BUTTON, I can recommend calling the cm_SwitchHidSys command in Total Commander.
Reason: 'Everything' ALWAYS shows hidden (e.g. descript.ion) and hidden & system files (e.g. Thumbs.db) in the search results.
This avoids that the number of files in [the footer -> 13.2.e of] 'Everything' and Total Commander
- after the transfer of the search result - is different and that the AHK script gives a hint message.

In the explanations for the button, I also indicated which parameters I generally consider to be as mandatory or optional.

Button 1 with command: cm_SrcViewModeList Branch_View

Code: Select all

TOTALCMD#BAR#DATA
cm_SrcViewModeList Branch_View

%COMMANDER_PATH%\Tools\AutoHotkey\AutoHotkey.exe
AHK script 4.10.2022 || cm_SrcViewModeList Branch_View|Columns view: 37 Pfad (=Path) || Sort order: Unchanged|Auto-run commands: em_EV-results_TC-LOADLIST,CM_WAIT 750,cm_ExchangeSelBoth|em_EV-results_TC-LOADLIST: Path\to\Compiled_AHK_Script_04-10-2022.exe


-1
Button 2 with command: em_EV-results_TC-LOADLIST,CM_WAIT 750,cm_ExchangeSelBoth

Code: Select all

TOTALCMD#BAR#DATA
em_EV-results_TC-LOADLIST,CM_WAIT 750,cm_ExchangeSelBoth

%COMMANDER_PATH%\Tools\AutoHotkey\Skripte\EV_SearchResults_to_TC-panel\SEND_EV-RESULTS_to_TC-panel_(A)_CloseEverything-0_TAB-Search_result_(A).exe
AHK script 4.10.2022 || WITHOUT 'Custom columns view'|em_EV-results_TC-LOADLIST,CM_WAIT 750,cm_ExchangeSelBoth|Run %TotalCmd% /O /T /S LOADLIST:%DestinationFile% || Tab "Search result:" in Total Commander

0
-1
  1. Mandatory > Folder: "EV-Results" -> e.g. %COMMANDER_PATH%\EV-Results\ ... C:\totalcmd\EV-Results\
  2. Optional (recommended) > View Mode - Name: <Default>
    1. Optional (recommended) > Columns view: Full
    2. Optional (recommended) > Sort order:      Name
  3. Mandatory > View Mode - Name: Branch_View
    1. Optional    > Columns view: 37 Pfad ('Pfad' = Path - see: 3.d for details)
    2. Mandatory > Sort order:      Unchanged
    3. Mandatory > Auto-run commands: em_EV-results_TC-LOADLIST
      • em_EV-results_TC-LOADLIST -> Path\to\Compiled_AHK_Script_04-10-2022.exe, e.g. ...
        usercmd.ini

        Code: Select all

        [em_EV-results_TC-LOADLIST]
        cmd=%COMMANDER_PATH%\Tools\AutoHotkey\Skripte\Compiled_AHK_Script_04-10-2022.exe
        Compiled_AHK_Script_04-10-2022.exe - Line 164:

        Code: Select all

        Run %TotalCmd% /O /T /S LOADLIST:%DestinationFile%
        Parameter: /O, /T, /S, LOADLIST -> please see Help (F1): 4.a. Command line parameters
    4. Optional > Columns view: 37 Pfad (## Custom columns view) ...
      Columns view: 37 Pfad (= 37 Path) - fields: Name, Ext, [=tc.size], [=tc.writedate], [=tc.attributestr], [=tc.path]
    5. Optional > Auto-run commands: cm_SrcSortByCol6   6006
      This command sorts the 6th column from the 'Custom columns view' (e.g. Pfad =Path) in ascending order.
      The setting in Everything: "Mix Files and Folders" does not apply in Total Commander in this case..
      Columns view: 37 Pfad (= 37 Path), Auto-run commands: em_EV-results_TC-LOADLIST,CM_WAIT 750,cm_SrcSortByCol6
    6. Optional > CM_WAIT 750 -> CM_WAIT <time>   Wait x milliseconds -> only mandatory in combination with: cm_ExchangeSelBoth
      and cm_SrcSortByCol6, e.g. em_EV-results_TC-LOADLIST,CM_WAIT 750,cm_SrcSortByCol6
      It is difficult to determine the timeout value if there are many search results to be transferred.
      If necessary, it is advisable to simply press a button with the command: cm_ExchangeSelBoth.
    7. Optional > Auto-run commands: cm_ExchangeSelBoth (mandatory: CM_WAIT 750, e.g. CM_WAIT 750,cm_ExchangeSelBoth)
      cm_ExchangeSelBoth  -> cm_ExchangeSelBoth  3321  Invert selection (files+folders)
      ... and show the number of files and folders in the status bar of Total Commander.
      See also: OPTIONAL - Display (Objects, folders, files) in footer of 'Everything' -> Point 13.2.e
  4. Optional > Button with command: %COMMANDER_EXE% /O /T /S LOADLIST:%COMMANDER_PATH%\EV-Results\EV-Results.txt
    ... opens a NEW tab "Search result:" in Total Commander and displays the contents of the file "EV-Results.txt".
    Parameter: /O, /T, /S, LOADLIST -> please see Help (F1): 4.a. Command line parameters
     
  5. Optional > Button with command: OPENTABSL %COMMANDER_PATH%\TABs\STANDARD.tab
    OPENTABS <filename> ... Open tabs from saved .tab file ... Helps restore order to tabs.
- Compiled_AHK_Script_04-10-2022.AHK - still without compiling (.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
}

- Compiled_AHK_Script_04-10-2022.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
;********************************************************************************************************


Button 3 ............. - View Mode + Custom colums view / AHK script 21.10.21

Code: Select all

TOTALCMD#BAR#DATA
cm_SrcViewModeList EV-Results

%COMMANDER_PATH%\Tools\AutoHotkey\AutoHotkey.exe,2
AHK script 21.10.2021 || cm_SrcViewModeList EV-Results|Columns view: 37 Pfad (=Path) || Sort order: Unchanged|Auto-run commands:em_EV-results_AHK-script_21.10.2021_EXE,em_LOAD_EV-Results_TC-LOADLIST,CM_WAIT 750,cm_ExchangeSelBoth|Tab "Search result:" in TC

0
-1
  1. Mandatory > Folder: "EV-Results" -> e.g. %COMMANDER_PATH%\EV-Results\ ... C:\totalcmd\EV-Results\
  2. Mandatory > View Mode - Name   -> e.g. EV-Results
    1. Optional    > Columns view: 37 Pfad ('Pfad' = Path - see above: 3.d for details)
    2. Mandatory > Sort order:      Unchanged
    3. Mandatory > Auto-run commands: em_EV-results_AHK-script_21.10.2021_EXE, em_LOAD_EV-Results_TC-LOADLIST
      (Auto-run commands: > Complete field content, e.g.
      em_EV-results_AHK-script_21.10.2021_EXE,em_LOAD_EV-Results_TC-LOADLIST,CM_WAIT 750,cm_ExchangeSelBoth).
      • em_EV-results_AHK-script_21.10.2021_EXE -> Path\to\Compiled_AHK_Script_21.10.2021.exe, e.g. ...
        usercmd.ini

        Code: Select all

        em_EV-results_AHK-script_21.10.2021_EXE
        cmd=%COMMANDER_PATH%\Tools\AutoHotkey\Skripte\EV_SearchResults_to_TC-panel\Compiled_AHK_Script_21.10.2021.exe
        Compiled_AHK_Script_21.10.2021.exe - Line 164:

        Code: Select all

        Run %TotalCmd% /O /T /S %DestinationDir%
      • em_LOAD_EV-Results_TC-LOADLIST -> %COMMANDER_EXE% /O /T /S LOADLIST:%COMMANDER_PATH%\EV-Results\EV-Results.txt
        usercmd.ini

        Code: Select all

        [em_LOAD_EV-Results_TC-LOADLIST]
        cmd=%COMMANDER_EXE% /O /T /S LOADLIST:%COMMANDER_PATH%\EV-Results\EV-Results.txt
        Parameter: /O, /T, /S, LOADLIST -> please see Help (F1): 4.a. Command line parameters
  3. All OTHER *OPTIONAL* SETTINGS correspond to the settings in BUTTON 1 -> see there... (!)
- Compiled_AHK_Script_21-10-2021.AHK - still without compiling (.exe)

Code: Select all

; Transfer Everything GUI results to TC
; Authors: Horst.Epp & Ovg
; Last modified: 21.10.2021 (Changed RegEx by Ovg) ........ If !RegExMatch(content,"i)^(?:[a-z]:|\\\.*?\\)")

; 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; 0 for NO)
	;    Should Everything GUI window be closed after transferring search results to TC
	; UseInstance (Empty for default instance)
        ;    Name of the Everything instance to be used for closing the GUI window

; 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 %DestinationDir%
	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
}
- Compiled_AHK_Script_04-10-2022.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; 0 for NO)
;    Should Everything GUI window be closed after transferring search results to TC
; UseInstance (Empty for default instance)
;    Name of the Everything instance to be used for closing the GUI window

; 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
;********************************************************************************************************


Windows 11 Pro (x64) Version 22H2 (OS build 22621.674) | TC 10.52RC3 x64 | 'Everything' 1.5.0.1323a (x64)
Open Everything GUI results with TC LOADLIST - AutoHotkey (.AHK) SCRIPT and GUIDANCE, discussions
Transfer 'Everything' GUI results to Total Commander - STEP-BY-STEP GUIDE, summary - Status: AHK script dated 21.10.2021 - (Not yet adjusted)
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) »

Moderator message

Moved to fixed bugs
Author of Total Commander
https://www.ghisler.com
Post Reply